C# 连接SQLServer操作数据库问题

C#联合SQLServer开发时连接数据库报错connection 连接问题

报错信息:

This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the original database connection has been opened and credentials have been removed from the connection string. Supply an unopened connection.

解决方案:

1、connection配置中加入: Integrated Security=True,表示可以在不知道数据库用户名和密码的情况下,依然可以连接数据库

2、connection配置中加入:Persist Security Info = True,表示数据库连接成功后是否保存密码信息

连接字符串可配置为:string connectionString=@"服务器名称;Database=数据库名称;User Id=用户名称;Integrated Security=True";

相关推荐
烛阴29 分钟前
隐式vs显式:解密C#类型转换的底层逻辑
前端·c#
爬山算法39 分钟前
Redis(127)Redis的内部数据结构是什么?
数据结构·数据库·redis
应用市场1 小时前
Qt QTreeView深度解析:从原理到实战应用
开发语言·数据库·qt
梦里不知身是客111 小时前
kafka作为Sink
c#·linq
q***96581 小时前
Spring Data JDBC 详解
java·数据库·spring
猿来是你_L1 小时前
C# Dictionary 转换成 List
windows·c#·list
Hello,C++!1 小时前
linux下libcurl的https简单例子
linux·数据库·https
kokunka2 小时前
C#类修饰符功能与范围详解
java·开发语言·c#
合方圆~小文2 小时前
高性能20倍变焦球机转动功能监控设备
数据结构·数据库·数码相机·模块测试
mudtools2 小时前
.NET驾驭Excel之力:工作簿与工作表操作基础
c#·.net·excel