ExecuteReader: Connection 属性尚未初始化。
protectedvoidButton1_Click(objectsender,EventArgse){stringnamed=TextBox2.Text;stringC...
protected void Button1_Click(object sender, EventArgs e)
{
string named = TextBox2.Text;
string Connection = "Provider=Microsoft.Jet.OleDb.4.0;";
Connection += @"Data Source=E:\WebSite1\db1\cj.mdb";
OleDbConnection objConnection = new OleDbConnection(Connection);
objConnection.Open();
string sql = "select [name],[password] from zhuce where name='" + named + "'";
OleDbCommand Olcmd = new OleDbCommand();
OleDbDataReader dr = Olcmd.ExecuteReader();
if (dr.Read())
{
Label5.Text = "<p>姓名:" + Convert.ToString(dr["name"]) + "</p><p>密码:" + Convert.ToString(dr["password"]) + "</p>";
}
else
{
Response.Write("<script type='text/javascript' >alert('您输入的信息有误,请返回后重新输入')</script>");
}
各位高手帮忙看下哪的错误,我郁闷死了都·非常感谢的 展开
{
string named = TextBox2.Text;
string Connection = "Provider=Microsoft.Jet.OleDb.4.0;";
Connection += @"Data Source=E:\WebSite1\db1\cj.mdb";
OleDbConnection objConnection = new OleDbConnection(Connection);
objConnection.Open();
string sql = "select [name],[password] from zhuce where name='" + named + "'";
OleDbCommand Olcmd = new OleDbCommand();
OleDbDataReader dr = Olcmd.ExecuteReader();
if (dr.Read())
{
Label5.Text = "<p>姓名:" + Convert.ToString(dr["name"]) + "</p><p>密码:" + Convert.ToString(dr["password"]) + "</p>";
}
else
{
Response.Write("<script type='text/javascript' >alert('您输入的信息有误,请返回后重新输入')</script>");
}
各位高手帮忙看下哪的错误,我郁闷死了都·非常感谢的 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询