我不知道如何将SQLite表中的列名存储到字符串列表中。 下面的代码填充与列名一个DataGridView(除其他事项外):SQLite - 将表名的列名存储在字符串列表中
string sDatabasePath = DBPath();
SQLiteConnectionStringBuilder datasource = new SQLiteConnectionStringBuilder();
datasource.Add("Data Source", sDatabasePath);
datasource.Add("Version", "3");
datasource.Add("New", "False");
datasource.Add("Compress", "True");
using (SQLiteConnection connection = new SQLiteConnection(datasource.ConnectionString))
{
connection.Open(); //opens connection
SQLiteCommand getColumnNames = new SQLiteCommand("PRAGMA table_info('myTable');", connection);
SQLiteDataAdapter myAdapter = new SQLiteDataAdapter(getColumnNames);
DataSet myDataSet = new DataSet();
//myAdapter.Fill(myDataSet, "name");
this.dataGridView1.DataSource = myDataSet;
this.dataGridView1.DataMember = "name";
connection.Close();
}
的表名通常在数据网格添加? –
在datagrid中,我正确地获取了列名(datagrid中的第一列称为name,每行都是我表中列的名称,datagrid中的第二列称为cid,第三类,第四个not_null等)。 –