[OLE DB] system.data.oledb.oledbexception:'from子句中的语法错误。' [英] [OLE DB] system.data.oledb.oledbexception : 'syntax error in from clause.'
问题描述
我有这个错误文本System.Data.OleDb.OleDbException :FROM子句中的语法错误。 '
i不知道为什么会这样做这个错误信息
请你能帮帮我吗?
代码:
Hi,
I have this error text "System.Data.OleDb.OleDbException : 'Syntax error in FROM clause.'"
i didn't know why that's doing this error message
Please Can you help me ?
Code :
private void Form1_Load(object sender, EventArgs e)
{
using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\DataBase\Test.accdb"))
{
OleDbCommand command = new OleDbCommand("SELECT * FROM note", con);
con.Open();
OleDbDataReader reader = command.ExecuteReader();
listBox1.Items.Clear();
while (reader.Read())
{
listBox1.Items.Add(reader[0].ToString());
}
reader.Close();
}
}
我只是想获取我的Databass Note并在列表框上打印
我尝试过:
我有另一个项目与其他Databass(更重要)和代码没有错误我需要做的其他项目请帮助我。
Im just trying to get my Databass Note and to print on listbox
What I have tried:
I have another project with other Databass (more important) and the code didn't have an error what i need to do for my other project please help me.
<pre lang="c#"> using (OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=testapp.accdb"))
{
OleDbCommand command = new OleDbCommand("SELECT * FROM T_article",con);
con.Open();
OleDbDataReader reader = command.ExecuteReader();
lbxTableau.Items.Clear();
while (reader.Read())
{
lbxTableau.Items.Add(reader[0].ToString());
}
reader.Close();
}
i真的需要为我的程序读取我的数据库:(
i really need to read my databass for my programme :(
推荐答案
如果你对表使用保留字,你可以在它们周围加上方括号,让它知道你不是指保留字,而是一个叫那个字的表。
If you use reserved words for tables you put square brackets around them to let it be known you are not referring to the reserved word but a table called that word.
OleDbCommand command = new OleDbCommand("SELECT * FROM [note]", con);
Note是一个访问关键字:访问2007保留字和符号 - 访问 [ ^ ] - 要将其用作表名,必须将其转义:
"Note" is an access keyword: Access 2007 reserved words and symbols - Access[^] - to use it as a table name it must be escaped:
OleDbCommand command = new OleDbCommand("SELECT * FROM [note]", con);
这篇关于[OLE DB] system.data.oledb.oledbexception:'from子句中的语法错误。'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!