c#中的连接字符串登录错误? [英] connection string login error in c# ?

查看:73
本文介绍了c#中的连接字符串登录错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Cannot open database "mydb" requested by the login. The login failed.





我的连接字符串是:





my connection string is :

public string connectionstring =
      @"Data Source=SSD-PC\SSD;Initial Catalog=mydb;user=sa;password=sa;Integrated Security=True";

推荐答案

您好,



将您的集成安全值更改为false 。



Hi,

Change your Integrated Security value to false.

public string connectionstring =
      @"Data Source=SSD-PC\SSD;Initial Catalog=mydb;user=sa;password=sa;Integrated Security=false";





虽然Integrated Security设置为True ,将使用基于Windows的凭据尝试连接 - 即它将忽略连接字符串中的用户名/密码值。



希望它有所帮助。



Whilst Integrated Security is set to True, the connection will be attempted using the Windows based credentials - i.e. it will ignore the username/password values in the connection string.

Hope it helps.


如果要使用Windows身份验证模式登录然后你需要编写Integrated Security = true而不是用户名和密码

public string connectionstring =

@Data Source = SSD-PC\SSD; Initial Catalog = mydb ;集成安全性=真;







如果想使用SQL Server身份验证模式登录然后你需要编写用户ID和密码而不是Integrated security = true其他你可以编写Integrated Security = false



@Data Source = SSD-PC\SSD ;初始目录= mydb;集成安全性=假;用户id = sa;密码= sa;;







@Data Source = SSD-PC\SSD; Initial Catalog = mydb; user id = sa; password = sa;;
if want to log in with windows authentication mode then you need to write Integrated Security=true instead of username and password
public string connectionstring =
@"Data Source=SSD-PC\SSD;Initial Catalog=mydb;Integrated Security=true";



if want to log in with SQL server authentication mode then you need to write user id and password instead of Integrated security= true other wise you can write Integrated Security=false

@"Data Source=SSD-PC\SSD;Initial Catalog=mydb;Integrated Security=false;user id=sa;password=sa;";

or

@"Data Source=SSD-PC\SSD;Initial Catalog=mydb;user id=sa;password=sa;";


删除Integrated Security或设置它假的
delete Integrated Security or set it to false


这篇关于c#中的连接字符串登录错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆