操作access数据库的问题,请大家帮忙看看啊,很急啊!!!!
我想对access数据库进行操作,先检查一下用户名是否存在,然后在写入数据库!我运行时系统提示CS0143: 类型“System.Data.OleDb.OleDbDataReader”未定义构造函数
错误行在 :OleDbDataReader xy = new OleDbDataReader ();
请大家帮忙解决啊,很急啊!!!
OleDbConnection conn = new OleDbConnection();
conn .ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/Backup/我的文档/txl/App_Data\txl.mdb";
conn.Open ();
string xyname,xy易做图;
xyname=TextBox1.Text .Trim ();
xy易做图 =DropDownList1.Text ;
string xysql;
xysql ="select * from xiaoyou where xy_name="+xyname +"";
OleDbCommand xycmd = new OleDbCommand (xysql ,conn);
OleDbDataReader xy = new OleDbDataReader ();
if (xy.Read ())
{
Response .Write ("right");}
else
{ Response .Write ("wrong");} --------------------编程问答-------------------- xysql ="select * from xiaoyou where xy_name='"+xyname +"'";
数据库文件也最好用相对路径:Server.MapPath()
OleDbDataReader xy = new OleDbDataReader ();'只是创建一个OleDbDataReader对象的实例
还需要xycmd的ExecuteReader()方法才行
下面vb.net的代码:
Cmd = New OleDbCommand(SQL, Conn)
Rd = Cmd.ExecuteReader()
--------------------编程问答-------------------- using system.data.oledb --------------------编程问答-------------------- OleDbDataReader xy = Cmd.ExecuteReader() ;
补充:.NET技术 , ASP.NET