我在将数据填充到 datagridview 控件时遇到问题。这是我的代码。
string sqlQuery = "SELECT * FROM Table;";
string source = "Data Source=E:\\Documents\\Database\\Database.sdf;" +
"Password=password;Persist Security Info=False;";
SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(sqlQuery, source);
SqlCeCommandBuilder commBuilder = new SqlCeCommandBuilder(dataAdapter);
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
dbBindSource.DataSource = table;
dbGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
dbGridView.ReadOnly = true;
dbGridView.DataSource = dbBindSource;
这在表单加载时运行无济于事。任何人?