asp.net里面如何用oldb datareader 读取一个数据库字段的值然后赋给一个变量
stringdbname=Server.MapPath("App_Data/userinfo.mdb");stringstrConnection="Provider=Mi...
string dbname = Server.MapPath("App_Data/userinfo.mdb");
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0; Data Source='" + dbname + "'";
OleDbConnection con = new OleDbConnection(strConnection);
con.Open();
string sqlstr;
sqlstr ="select tel from userinfo where uname='" + Request.QueryString["name"] + "' and upwd='" + Request.QueryString["password1"] + "'";
OleDbCommand cmd=new OleDbCommand(sqlstr,con);
OleDbDataReader dr=cmd.ExecuteReader();
int xuehao;
xuehao = dr["tel"]; 就是想把Tel赋给学号!!!这样会报错! 展开
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0; Data Source='" + dbname + "'";
OleDbConnection con = new OleDbConnection(strConnection);
con.Open();
string sqlstr;
sqlstr ="select tel from userinfo where uname='" + Request.QueryString["name"] + "' and upwd='" + Request.QueryString["password1"] + "'";
OleDbCommand cmd=new OleDbCommand(sqlstr,con);
OleDbDataReader dr=cmd.ExecuteReader();
int xuehao;
xuehao = dr["tel"]; 就是想把Tel赋给学号!!!这样会报错! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询