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";

相关推荐
豆沙沙包?38 分钟前
2025年--Lc171--H175 .组合两个表(SQL)
数据库·sql
麋鹿原1 小时前
Android Room 数据库之数据库升级
数据库·kotlin
GanGuaGua2 小时前
MySQL:表的约束
数据库·mysql
Li zlun3 小时前
MySQL 性能监控与安全管理完全指南
数据库·mysql·安全
William_cl4 小时前
C# MVC 修复DataTable时间排序以及中英文系统的时间筛选问题
开发语言·c#·mvc
养生技术人4 小时前
Oracle OCP认证考试题目详解082系列第48题
运维·数据库·sql·oracle·database·开闭原则·ocp
c#上位机4 小时前
wpf之RelativeSource用法总结
c#·wpf
海阳宜家电脑4 小时前
Lazarus使用TSQLQuery更新的一点技巧
数据库·lazarus·tsqlquery
Dm_dotnet5 小时前
WPF应用最小化到系统托盘
c#
丨我是张先生丨5 小时前
SQLSERVER 查找存储过程中某个变量
数据库