string strSQL = "insert into user values ";
strCon += "('" + this.username_txt.Text + "','" + this.password_txt.Text + "','" + this.email_txt.Text + "','" + this.address_txt.Text + "',";
strSQL += "' " + this.familyname_txt.Text + "','" + this.givenname_txt.Text + "','" + this.idcard_txt.Text + "')";
请问这个插入语言有问题吗?注册过后找不到注册的信息,也就是说没能成功插入到user表中。
整个代码如下:
string strCon = WebConfigurationManager.ConnectionStrings["RAINBOWConnectionString"].ConnectionString;
SqlConnection sql = new SqlConnection();
sql.ConnectionString = strCon;
sql.Open();
SqlCommand cmd = new SqlCommand("select * from [user] where username='" + this.username_txt.Text + "'", sql);
SqlCommand cmd2 = new SqlCommand("select * from [user] where email='" + this.email_txt.Text + "'", sql);
string strSQL = "insert into user values ";
strCon += "('" + this.username_txt.Text + "','" + this.password_txt.Text + "','" + this.email_txt.Text + "','" + this.address_txt.Text + "',";
strSQL += "' " + this.familyname_txt.Text + "','" + this.givenname_txt.Text + "','" + this.idcard_txt.Text + "')";
SqlCommand cmd3 = new SqlCommand(strSQL, sql);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
this.Label1.Visible = true;
dr = cmd2.ExecuteReader();
if (dr.Read())
{
this.Label2.Visible = true;
sql.Close();
}
}
else
{
this.Label1.Visible = false;
this.Label2.Visible = false;
Server.Transfer("~/前台/Login.aspx");
}
sql.Close();