第一种:
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @"server=PC2011090921FPF\SQLEXPRESS; Integrated Security=true; Initial Catalog=Register";
conn.Open();
SqlCommand cmd = new SqlCommand("select * from [user] where UserName='" + this.TextBox1.Text + "'", conn);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
MsgBox(sdr["UserName"].ToString());
}
else
{
MsgBox("没?有®D用®?户¡ì!ê?");
}
第二种方法:
SqlConnection conn = new SqlConnect