你好,你以前说的那个问题我现在遇到了,该怎么解决啊,运行到da.Fill(ds);时会提示无效的 SQL语句
stringconnectionString="Provider=Microsoft.ACE.OLEDB.12.0;DataSource=E:/access/access...
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:/access/access2.accdb";
OleDbConnection myconnection = new OleDbConnection(connectionString);
myconnection.Open();
string sql = "Select * form fittingmessageInfo where 车号 = ' " +chehao.Text.Trim()+" ' ";
OleDbDataAdapter da = new OleDbDataAdapter(sql, myconnection);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables["fittingmessageInfo"]; 展开
OleDbConnection myconnection = new OleDbConnection(connectionString);
myconnection.Open();
string sql = "Select * form fittingmessageInfo where 车号 = ' " +chehao.Text.Trim()+" ' ";
OleDbDataAdapter da = new OleDbDataAdapter(sql, myconnection);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables["fittingmessageInfo"]; 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
2015-05-04
展开全部
把这2句改一下:
string sql = "Select * form fittingmessageInfo where 车号 = ' " +chehao.Text.Trim()+" ' ";
OleDbDataAdapter da = new OleDbDataAdapter(sql, myconnection);
-----------------------------------------------
string sql = "Select * form fittingmessageInfo where 车号 = @a";
OleDbDataAdapter da = new OleDbDataAdapter(sql, myconnection);
da.SelectCommand.Parameters.AddValues("@a",chehao.Text.Trim());
---------------------------------------------------------------------------------------
前提是这个fittingmessageInfo表里面必须有一个列,名称为"车号",否则怎么改都是错误的sql
string sql = "Select * form fittingmessageInfo where 车号 = ' " +chehao.Text.Trim()+" ' ";
OleDbDataAdapter da = new OleDbDataAdapter(sql, myconnection);
-----------------------------------------------
string sql = "Select * form fittingmessageInfo where 车号 = @a";
OleDbDataAdapter da = new OleDbDataAdapter(sql, myconnection);
da.SelectCommand.Parameters.AddValues("@a",chehao.Text.Trim());
---------------------------------------------------------------------------------------
前提是这个fittingmessageInfo表里面必须有一个列,名称为"车号",否则怎么改都是错误的sql
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询