首页 > 数据库技术 > 详细

VS2010连接SQLite数据库

时间:2016-10-21 20:08:49      阅读:401      评论:0      收藏:0      [点我收藏+]

 Visual studio 2010及以上版本,连接SQLite数据库

1、在Sqlite开发站点下载SQLite的.exe安装包

 

Ctrl+F搜索这条语句:This is the only setup package that is capable of installing the design-time components for Visual Studio xxxx

找到对应的VS版本,注意一定要带bundle,集成了设计器;无论32位系统还是64位系统,似乎都要下载32位的(X86)

 

如下图:

 技术分享

 

否则,在Visual Studio中想添加新数据库时没有Sqlite这个选项,下载正确并安装后,在VS中可看到SQLite:

技术分享

 

 2、连接数据库

添加连接--database:db文件

 2、VS2010 在窗体中拉一个按钮和DataGridView,实现点击按钮,在DataGridView显示数据库中的数据

   private void button1_Click(object sender, EventArgs e)
        {
            using (SQLiteConnection con = new SQLiteConnection(Constants.DATA_SOURCE))
            {
                con.Open();
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = con;
                    cmd.CommandText = string.Format("select * from  jy_cdjy_cdjyhgz");
                    int rows = cmd.ExecuteNonQuery();
                    SQLiteDataAdapter oraDA = new SQLiteDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    oraDA.Fill(ds);
                    //con.Close();
                    DataTable dtbl = ds.Tables[0];
                    this.dataGridView1.DataSource = dtbl;
                }
            }





        }

  

 

 

 

参考:

http://blog.csdn.net/missautumn/article/details/18567715

VS2010连接SQLite数据库

原文:http://www.cnblogs.com/Donnnnnn/p/5985639.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!