• WPF sqlite 数据库入门


    nuget 包,安装   System.Data.SQLite.Core  

    引用    using System.Data.SQLite;

    可以安装 SQLite Expert 软件 

    方法一

    #region sqlite3
                    
                    string dbPath = System.IO.Path.Combine(Environment.CurrentDirectory, "zk20200828.db");
                    string connString = string.Format("Data Source={0}", dbPath);
    
                    using (SQLiteConnection conn = new SQLiteConnection(connString))
                    {
                        StringBuilder query = new StringBuilder();
                        query.Append("SELECT * ");
                        query.Append("FROM Teacher1 ");
    
                        using (SQLiteCommand cmd = new SQLiteCommand(query.ToString(), conn))
                        {
                            conn.Open();
    
                            using (SQLiteDataReader dr = cmd.ExecuteReader())
                            {
                                while (dr.Read())
                                {
                                    Console.WriteLine("SQLiteDataReader {0} {1} {2}",
                                        dr.GetValue(0),
                                        dr.GetValue(1),
                                        dr.GetValue(2));
                                }
                            }
                        }
                    }
                    
                    #endregion
    

      

    方法二

                    #region sqlite 2
                    
                    string dbConnectionString = @"Data Source=E:CodeACCESS_PictrueCraftTheWorldPcSqLiteinDebugzk20200828.db;Version=3;";
                    try
                    {
                        SQLiteConnection sqlite_con = new SQLiteConnection(dbConnectionString);
                        sqlite_con.Open();
                        string query = "select * from Teacher1;";
                        SQLiteCommand sqlite_cmd = new SQLiteCommand(query, sqlite_con);
                        SQLiteDataReader dr = sqlite_cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            Console.WriteLine("SQLiteDataReader{0}",dr.GetString(1));
                         //   MessageBox.Show(dr.GetString(1));
                        }
    
                        sqlite_con.Close();
                    }
                    catch (Exception ex)
                    {
                    //    MessageBox.Show(ex.ToString());
                        Console.WriteLine("SQLiteDataReader{0}",ex.ToString());
                    }
                    
                    #endregion
    

      

  • 相关阅读:
    安装Python及工具
    Python能做什么
    学习Python前序
    [摘]selenium-ide命令
    [摘]selenium-ide编辑命令
    selenium-ide学习
    敏捷个人课后练习:管理情绪
    敏捷个人课后练习:释放情绪
    敏捷个人课后练习:接纳情绪
    敏捷个人课后练习:承诺
  • 原文地址:https://www.cnblogs.com/zhangkun35268/p/13580030.html
Copyright © 2020-2023  润新知