sqlite数据库的使用

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();
         }
/ // <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数据库需要的引用的库下载地址:

01-07 13:30