无法打开登录所请求的数据库 "DepartmentStore"。登录失败。
string msg = "";
string ConnString;
ConnString = @"Data Source=(local);Initial Catalog=DepartmentStore;Integrated Security=true;";
SqlConnection coon = new SqlConnection(ConnString);
coon.Open();
string selectCmd = "select * from Admin where adminId='" + textBox1.Text + "'and password='" + textBox2.Text + "'";
SqlCommand cmd = new SqlCommand(selectCmd, coon);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
system f1 = new system();
f1.Show();
}
else
{
msg = "【账号】或【密码】错误,请重新输入!";
MessageBox.Show(msg, "登录失败");
}
coon.Close();
dr.Close();
[解决办法]
楼主的链接字符串都没有用户名和密码怎么登陆?
菜鸟路过,说错别怪。嘻嘻