早教吧作业答案频道 -->其他-->
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在system.data.dll中主要代码:是在form里的usingSystem;usingSystem.Data;usingSystem.Data;usingSystem.Data.OleDb;usingSystem.Drawing;usingSystem.Collections;usingSy
题目详情
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在system.data.dll中
主要代码:是在form里的
using System;
using System.Data;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
OleDbConnection connection1 = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source =c:\\db.mdb");
string sql = "select name,password from user where name ='" + textBox1.Text + "'";
connection1.Open();
OleDbDataAdapter adp = new OleDbDataAdapter(sql,connection1);
DataSet ds = new DataSet();
adp.Fill(ds); 就是这行代码有问题.
我try catch后的异常显示:
System.Data.OleDb.OleDbException:FROM 子句语法错误.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams,Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior,String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand command,CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand command,CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
主要代码:是在form里的
using System;
using System.Data;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
OleDbConnection connection1 = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source =c:\\db.mdb");
string sql = "select name,password from user where name ='" + textBox1.Text + "'";
connection1.Open();
OleDbDataAdapter adp = new OleDbDataAdapter(sql,connection1);
DataSet ds = new DataSet();
adp.Fill(ds); 就是这行代码有问题.
我try catch后的异常显示:
System.Data.OleDb.OleDbException:FROM 子句语法错误.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams,Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior,String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand command,CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand command,CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
▼优质解答
答案和解析
user是关键字,需要用 []转义.如:
string sql = "select name,password from [user] where name ='" + textBox1.Text + "'";
string sql = "select name,password from [user] where name ='" + textBox1.Text + "'";
看了 未处理的“System.Da...的网友还看了以下:
设数组data[O…m]作为循环队列sq的存储空间,front为队头指针,rear为队尾指针,则执行 2020-05-24 …
S十V主谓结构S十V十F主系表结构S十V十O主谓宾结构SV十O1十O2主谓双宾结构S十V十O十C主 2020-06-12 …
如图.在双缝干涉实验中,若用λ=5×10-7m的光照射.屏上O点是中央亮纹,屏上A点为第二级亮纹所 2020-06-21 …
长为L的绝缘细线下系一带正电的小球,其带电荷量为Q,悬于O点,如图所示.当在O点处固定一个正电荷时 2020-06-26 …
有一秒摆,悬点为O,在O点正下方O'处有一钉子,如图甲所示,摆从平衡位置向左摆时摆线碰到钉子摆长改 2020-07-31 …
一网球运动员在离开网的距离为12m处沿水平方向发球,发球高度为2.4m,网的高度为O.9m.(1)若 2020-10-30 …
(2013•厦门模拟)将一弹性绳(质量不计)一端固定在某一高处O点,另一端系在一个物体上,现将物体从 2020-11-02 …
如图所示,电流从A点分两路对称地通过圆环形支路再汇合于B点,则对圆环中心处O点的磁感应强度的描述正确 2021-01-13 …
如图所示,电流从A点分两路对称地通过圆环形支路再汇合于B点,则对圆环中心处O点的磁感应强度的描述正确 2021-01-13 …
如图所示,光滑圆弧形轨道半径R=10m,一小球A自最低点O开始在槽内做往复运动,当A开始运动时,离O 2021-01-14 …