本文介绍了使用用户实例= 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服务器作为用户用户",这可能是失败的原因. msdn.microsoft/en-us/library/bb264564 (v = sql.90).aspx [ ^ ],大约下降了1/3. 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. msdn.microsoft/en-us/library/bb264564(v=sql.90).aspx[^], about 1/3 of the way down.
更多推荐
使用用户实例= true时无法登录
发布评论