【发布时间】:2020-07-04 14:02:50
【问题描述】:
我正在使用 asp.net core 2.2 和 angular 7 开发一个 Web 应用程序。我的应用程序在本地运行,但是当我将应用程序和 SQL Server 数据库上传到 "1&1 Ionos" 托管服务器时,它无法连接到那里的数据库。
我尝试使用他们在数据库管理面板中提供的连接字符串,但它不起作用。
这是我在应用程序中使用的 appsettings。
{
"AppSettings": {
"Secret": "bla bla bla"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"CustomPosConnection": "Provider=sqloledb;Data Source=db784146660.hosting-data.io,1433;Initial Catalog=myDbName;User Id=myUserId;Password=myPass;"
}
}
这里 "myDb" ,"myUserId","myPass" 相当于实际的数据库名称,他们提供的实际用户 ID 和实际我在托管服务器中创建数据库时设置的密码。
请帮助我连接 1&1 ionos 托管服务器中的数据库,建议编写连接字符串或指导我还需要做什么,或者如果有人有连接到 SQL Server 的示例连接字符串,请分享来自 asp.net mvc 或 asp.net web api 或 asp.net core 应用程序的数据库,托管在 1&1 Ionos Windows 服务器。
【问题讨论】:
-
你应该为
Data Source值写你的服务器名或IP地址,你不需要在连接字符串中写sql端口。这是一个例子:"Data Source=192.168.5.17;Initial Catalog=DatabaseName;Integrated Security=false;UId=sa;pwd=123456;MultipleActiveResultSets=True" -
你为什么不试试寻求他们的支持呢?
-
不要使用集成安全 = false。它可能行不通。使用 Integrated Security = true 并消除用户名和密码。 SQL Server 默认使用 Windows 凭据 (true),它使用用户的 windows 帐户。通常我会创建一个 Windows 组帐户并将数据库设置为使用组帐户。然后将用途添加到组中,以便多个用途可以访问数据库。在使用组策略的公司网络中,组帐户已经存在。
标签: c# sql-server angular7 web-hosting asp.net-core-2.2