主题:[讨论]注册的连接不起来,求讨论
void btnSubmit_Click(Object Src,EventArgs E)
{
if(Page.IsValid)
{
String constr="server=(local);user id=sa;pwd=1111;database=log";
SqlConnection con=new SqlConnection(constr);
con.Open();
String sqltrc = "Select*From zhuce Where username=" + txtname.Text + "";
SqlCommand myCommand=new SqlCommand(sqltrc,con);
SqlDataReader reader=myCommand.ExecuteReader();
if(reader.Read())
{
Message.InnerHtml="该用户已经存在";
reader.Close();
}
else
{
reader.Close();
sqltrc="INSERT INTO zhuce VALUES ("+txtname.Text+","+txtpassword.Text+","+txtemail.Text+")";
myCommand.ExecuteNonQuery();
Message.InnerHtml="注册成功";
}
con.Close();
}
}
连接不起来,求讨论(zhuce是log里面的表)
{
if(Page.IsValid)
{
String constr="server=(local);user id=sa;pwd=1111;database=log";
SqlConnection con=new SqlConnection(constr);
con.Open();
String sqltrc = "Select*From zhuce Where username=" + txtname.Text + "";
SqlCommand myCommand=new SqlCommand(sqltrc,con);
SqlDataReader reader=myCommand.ExecuteReader();
if(reader.Read())
{
Message.InnerHtml="该用户已经存在";
reader.Close();
}
else
{
reader.Close();
sqltrc="INSERT INTO zhuce VALUES ("+txtname.Text+","+txtpassword.Text+","+txtemail.Text+")";
myCommand.ExecuteNonQuery();
Message.InnerHtml="注册成功";
}
con.Close();
}
}
连接不起来,求讨论(zhuce是log里面的表)