110,532
社区成员
发帖
与我相关
我的任务
分享
string user = this.textBox1.Text;
string pwd = this.textBox2.Text;
SqlConnection conn = new SqlConnection(@"Data Source=(local);Initial Catalog=master;Trusted_Connection=Yes;");
conn.Open();
SqlCommand cmd = new SqlCommand("select count(*) as flag from test where uid='"+user+"'and pwd ='" + pwd + "'", conn);
int flag = Convert.ToInt32(cmd.ExecuteScalar().ToString());
if (flag > 0)
{
Form2 frm = new Form2();
frm.Show();
this.Visible = false;
}
else
{
MessageBox.Show("出错", "出错");
}
可能连接字符串有问题!