我有这个代码:
public void FillData()
{
// 1 step. Open connection
string conection = @"Data Source=|DataDirectory|db.sdf;Persist Security Info=False;";
try
{
SqlCeConnection c = new SqlCeConnection(conection);
c.Open();
// 2 step. Create new DataAdapter
using (SqlCeDataAdapter a = new SqlCeDataAdapter("SELECT * FROM USER", c))
{
// 3 step. Use DataAdapter to fill table
DataTable t = new DataTable();
a.Fill(t);
// 4 step. Render data on the DataGridView
dataGridViewUsers.DataSource = t;
}
}
catch (SqlException e)
{
MessageBox.Show(e.Message);
}
}
我可以连接到数据库,但SqlCeDataAdapter
启动此错误:
There was an error parsing the query. [Token line number = 1, Token line offset = 15, Token in error = USER]
我的数据库有一个名为 的表USER
,那么这段代码有什么问题?