使用用户实例= true时无法登录

编程入门 行业动态 更新时间:2024-10-27 01:37:23
本文介绍了使用用户实例= 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时无法登录

本文发布于:2023-11-24 10:00:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624760.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实例   用户   true

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!