当前位置:首页 > 数据库 > SQlite

步步为营-58-SQLite的使用

System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SQLite; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Fuxi { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //00 构造数据的集合 List<ManagerInfo> listManager = new List<ManagerInfo>( ); //01-显示数据 //01-01 连接字符串"物理路径;版本号": string connStr = @"data source=F:UsershomeDocumentsVisual Studio 2013PaoDingJieNiuPDJN.db;version=3;"; //01-02 创建连接字符串 using (SQLiteConnection conn = new SQLiteConnection( connStr)) { //01-03 查询语句 SQLiteCommand cmd = new SQLiteCommand("select * from ManagerInfo",conn); //01-04 执行command conn.Open(); SQLiteDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { listManager.Add(new ManagerInfo() { Mid = Convert.ToInt32(reader["mid"]), Mname = reader["mname"].ToString(), Mpwd = reader["mpwd"].ToString(), Mtype =Convert.ToInt32( reader["mtype"]) }); } } //02 显示到datagridView上 dataGridView1.DataSource = listManager; } } } } 代码示例 步步为营-58-SQLite的使用 - 文章图片步步为营-58-SQLite的使用 - 文章图片
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Fuxi
{
   public partial class ManagerInfo
    {
        public int Mid { get; set; }
        public string Mname { get; set; }
        public string Mpwd { get; set; }
        public int Mtype { get; set; }
    }
}
ManagerInfo

步步为营-58-SQLite的使用 - 文章图片

步步为营-58-SQLite的使用

标签:class   reader   idt   task   nbsp   执行   visual   分享   代码示例   

本文系统来源:http://www.cnblogs.com/YK2012/p/6860873.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!