110,567
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
string str = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=tmall;Integrated Security=True";
SqlConnection conn = new SqlConnection(str);
conn.Open();
String selectsql = "Select * from client where name='" + textBox1.Text + "'and password='" + textBox2.Text + "'";
//原来的
SqlCommand cmd = new SqlCommand("selectsql", conn);
//修改为
SqlCommand cmd = new SqlCommand(selectsql, conn);
cmd.CommandType = CommandType.Text;
SqlDataReader sdr;
sdr = cmd.ExecuteReader();
if (sdr.Read())
{
test.Text = "登录成功";
}
else
{
test.Text = "登录失败";
return;
}
}