62,071
社区成员
发帖
与我相关
我的任务
分享
SqlConnection con1 = new SqlConnection(con);
con1.Open();
SqlCommand cmd1 = new SqlCommand("select count( * ) from Users where User_Name='" + name + "'", con1);
int k = int.Parse(cmd1.ExecuteScalar().ToString());
if (k > 0)
{
Label1.Visible = true;
Label1.Text = "对不起,该用户已存在!";
TextBox1.Text = "";
}
..............
SqlConnection con1 = new SqlConnection(con);
con1.Open();
SqlCommand cmd = new SqlCommand("select count(*) from Tab where name='" + TextBox1.Text.Trim() + "'", con1);
int j = int.Parse(cmd.ExecuteScalar().ToString());
if (j > 0)
{
Label1.Visible = true;
Label1.Text = "该用户已存在!";
Label1.ForeColor = System.Drawing.Color.Red;
TextBox1.Text = "";
}