用VS2010连接SQL2008,报错“无法打开登录所请求的数据库Archives,登录失败。用户BOYINET\liuyang登录失败”
问题1.报错中用户是我的计算机名,为什么?
问题2.我的数据库Archives的所有者是计算机名还是sa呢?
问题3.这个连接语句正确吗?我连不上数据库到底是数据库设置的不对还是语句写的不对?
对了,我的数据库设置的混合模式登录
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
MessageBox.Show("提示:请输入用户名和密码!", "警告");
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=Archives;Integrated Security=True;User id=sa;Password=123");
conn.Open();
SqlCommand cmd = new SqlCommand("select * from User where username ='" + textBox1.Text.Trim() + "' and password ='" + textBox2.Text.Trim() + "'", conn);
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
if (sdr.HasRows)
MessageBox.Show("登录成功!", "提示");
else
MessageBox.Show("提示:用户名或密码错误!", "警告");
conn.Close();
}
这是报错界面:
这是数据库Archives和登录名sa的属性设置