早教吧作业答案频道 -->其他-->
未处理的“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...的网友还看了以下:
连字成词(英语)l u o e b s r u s r e t o s w a e s r t e 2020-05-14 …
用这些英文字母拼词这些英文字母打乱了顺序.一个题目一个词.第一题:r,c,t,a,e,s,r第二题 2020-05-16 …
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在sys 2020-05-17 …
30之前给我答复,)一个数n的数字中为奇数的那些数字的和记为S(n),为偶数的那些数字的和记为E( 2020-06-05 …
a+b+c+d+e=abcde,a,b,c,d,e均是正整数,求e的最大值由于a,e在式中对称,故 2020-06-09 …
32个罗经点每个点怎么读出来?罗经中的32个罗经点(N.N/E.NNE.NE/N.NE.NE/EE 2020-06-19 …
3、将C,C,E,E,I,N,S等7个字母随机的排成一行,那末恰好排成英文单词SCIENCE的概率 2020-07-30 …
高数达人请进!微分方程问题已知:微分方程y'+ay=f(x)a>0得到通解为y(x)=e^(-ax 2020-08-02 …
关于我国南极考察站的经纬度位置,正确的是()A.长城站(58°E,62°S)B.中山站(76°W,6 2020-11-06 …
英语:下1.将下联打乱的字母组成单词,并写出汉语意思1.a,e,h,g,c,n[]2.e,i,s,t 2020-12-10 …