Access数据fromms访问数据库出错 [英] Error in Access data fromms access database
问题描述
我使用ms访问数据库开发了一个窗口应用程序。但是当我使用这个查询时它会向我显示以下错误。
这是我的代码。
< pre lang =cs> 尝试
{
adapter = new OleDbDataAdapter( select emp_id AS员工ID,emp_name AS员工姓名AND emp_deg AS员工指定按emp_name ASC排序 ,con);
ds = new DataSet(); // 学生 - > stud.accdb文件中的表名
adapter.Fill(ds, emp_salary跨度>);
// ds.Tables [0] .Constraints.Add(pk_sno,ds.Tables [0 ] .Columns [0],true); //为数据集中的Tables [0]创建主键
dataGridView1.DataSource = ds.Tables [ 0 < /跨度>];
}
catch (例外h)
{
MessageBox.Show(h.ToString());
}
SELECT语句包括保留单词或参数名称拼写错误或缺失,或标点符号不正确。试试这个:
选择 \\ temp_id AS [员工ID],emp_name AS [员工姓名],emp_deg AS [名称]
来自员工
订单 按 emp_name ASC
I had developed an window application by using ms access database.But when I using this query it show me the error below.
Here is my code.
try
{
adapter = new OleDbDataAdapter("select emp_id AS Employee ID,emp_name AS Employee Name AND emp_deg AS Designation from employee Order by emp_name ASC", con);
ds = new DataSet();//student-> table name in stud.accdb file
adapter.Fill(ds, "emp_salary");
//ds.Tables[0].Constraints.Add("pk_sno", ds.Tables[0].Columns[0], true);//creating primary key for Tables[0] in dataset
dataGridView1.DataSource = ds.Tables[0];
}
catch (Exception h)
{
MessageBox.Show(h.ToString());
}
The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
Try this:
select emp_id AS [Employee ID], emp_name AS [Employee Name], emp_deg AS [Designation] from employee Order by emp_name ASC
这篇关于Access数据fromms访问数据库出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!