使用用户实例= true时无法登录 [英] unable to login when using user instance=true
本文介绍了使用用户实例= true时无法登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "database=test;server=.\\sqlexpress;integrated security=true; user instance=true; user=user;password=passwd";
con.Open();
SqlCommand cmd=new SqlCommand();
cmd.Connection = con;
cmd.CommandType=CommandType.Text;
cmd.CommandText="insert into tbemp(Name,Address,Salary) values(@nm,@ad,@sal)";
cmd.Parameters.Add("@nm",SqlDbType.VarChar,50).Value=textBox1.Text;
cmd.Parameters.Add("@ad",SqlDbType.VarChar,50).Value=textBox2.Text;
cmd.Parameters.Add("@sal",SqlDbType.VarChar,50).Value=textBox3.Text;
cmd.ExecuteNonQuery();
}
无法打开登录请求的数据库测试".登录失败.
用户"user-PC \ Administrator"的登录失败.
可能是什么错误,请帮助.
[edit]添加了代码块-OriginalGriff [/edit]
Cannot open database "test" requested by the login. The login failed.
Login failed for user ''user-PC\Administrator''.
what can be the error,please help.
[edit]Code block added - OriginalGriff[/edit]
推荐答案
取出"user instance=true"
-它导致SQL Server尝试将您登录到SQl上的Windows服务器作为用户用户",这可能是失败的原因.
http://msdn.microsoft.com/en-us/library/bb264564 (v = sql.90).aspx [
Take"user instance=true"
out - it causes SQL server to try to log you in to Windows on the SQl server as the user "user" which is probably what is failing.
http://msdn.microsoft.com/en-us/library/bb264564(v=sql.90).aspx[^], about 1/3 of the way down.
这篇关于使用用户实例= true时无法登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文