时间:2021-07-01 10:21:17 帮助过:108人阅读
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数据库
标签:tar blog 窗体 idv eve ble ada -- string