使用Sql suger新建数据库失败
public static SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "Data Source=DESKTOP-2DUF58Q\\SQLEXPRESS;Initial Catalog=ZhaoxiFlowerDb2;Persist Security Info=True;User ID=sa;Password=123456",//连接符字串
DbType = DbType.SqlServer, //数据库类型
IsAutoCloseConnection = true //不设成true要手动close
});
报错: “A network-related or instance-specific error occurred while establishing a connection to SQL Server.26 - Error Locating Server/Instance Specified (Tried many things but couldn't find solution))
建立到SQL Server的连接时发生网络相关或实例特定的错误。 服务器未找到或无法访问。 验证实例名称是否正确,并将SQL Server配置为允许远程连接。 (提供程序:SQL网络接口,错误:26 - 指定错误定位服务器/实例)
经过搜索资料
修改代码
ConnectionString = "Data Source=localhost;Initial Catalog=ghTest;Persist Security Info=True;User ID=sa;Password=123456",//连接符字串
成功