求解C#,将SQLite数据库data.db中的表abgc查询结果集显示到窗体的DataGridView控件中
1个回答
展开全部
string ConnectStr = "Data Source=data.db";
string SearchComm = "select * from abgc";
SQLiteConnection selectConnection = new SQLiteConnection(ConnectStr);
DataSet dataSet = new DataSet();
if (selectConnection.State != System.Data.ConnectionState.Open) {
selectConnection.Open();
SQLiteCommand cmd = selectConnection.CreateCommand();
cmd.CommandText = SearchComm;
SQLiteDataAdapter adapter = new SQLiteDataAdapter(cmd);
adapter.Fill(dataSet);
selectConnection.Close();
}
dataGridView1.DataSource = dataSet.Tables[0];
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询