sqlite数据库使用

sqlite数据库的使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Data;
using System.Data.SQLite;//sqlite数据库需要的引用
 
namespace SupremeConsole
{
    class Program
    {
         
        static void Main(string[] args)
        {
            GetSqliteData();
            Console.ReadLine();
         }<br>
        /// <summary>
        /// 使用sqlite获取数据
        /// </summary>
        public static void GetSqliteData()
        {
            SQLiteConnection sqLiteConn = new SQLiteConnection("Data source=" + Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"), "mysqlite.db"));
            sqLiteConn.Open();
            SQLiteCommand sqLiteCmd = new SQLiteCommand
            {
                Connection = sqLiteConn,
                CommandType = CommandType.Text,
                CommandText = "select * from mydb"
            };
            SQLiteDataAdapter sqLiteDataAdapter = new SQLiteDataAdapter
            {
                SelectCommand = sqLiteCmd
            };
            DataSet dataSet = new DataSet();
            sqLiteDataAdapter.Fill(dataSet);
            sqLiteConn.Close();
            foreach (DataRow item in dataSet.Tables[0].Rows)
            {
                Console.WriteLine($"db_name:{item.ItemArray[2].ToString()},hash_value:{item.ItemArray[3].ToString()}");
            }
            //string ss =$"编号:{dataSet.Tables[0].Rows[0].ItemArray[2].ToString()},姓名:{dataSet.Tables[0].Rows[0].ItemArray[3].ToString()}";           
            //return ss;
        }
    }
}

  

运行结果:

 

 

sqlite数据库需要的引用的库如下:

 

 

 

sqlite数据库需要的引用的库下载地址:https://download.csdn.net/download/LongtengGensSupreme/11985402

 

posted @   龙骑科技  阅读(177)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示