这是我的代码:try
{
string phone = this.texone.Text.Trim();
string pwd = this.txtpwd.Text.Trim();
string pwd2 = this.textpwd2.Text.Trim();
string name = this.texname.Text.Trim();
string sex = "";
if (this.ckboy.Checked == true)
{
sex = "0";
}
else
{
sex = "1";
}
string Adress = this.txtAdress.Text.Trim();
string Idcard = this.txtIdCard.Text.Trim();
if (pwd.Equals(pwd2))
{
}
else
{
MessageBox.Show("两次密码不相等");
this.txtpwd.Focus();
}
con = new SqlConnection(conString);
con.Open();
string sql = string.Format("INSERT [User] VALUES('{0}','{1}','{2}','{3}','{4}','{5}')", phone, pwd, name, sex, Idcard, Adress);
SqlCommand com = new SqlCommand(sql, con);
int isRet = com.ExecuteNonQuery();
if (isRet>= 1)
{
MessageBox.Show("注册成功!");
}
else
{
MessageBox.Show("注册失败!");
}
}
catch (Exception)
{
MessageBox.Show("出现异常!");
throw;
}
con.Close();
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("确定要退出吗?");
this.Close();
}