简体   繁体   中英

How to connect MS SQL Server database from ASP.NET Core 2.2 hosted in **1&1 Ionos** hosting server?

I am developing a web application with asp.net core 2.2 and angular 7. My application is working locally but when I upload the application and SQL Server database to "1&1 Ionos" hosting server, it can't connect to the database there.

I tried with the connection string they provided in their database admin panel but it just not working.

Here is the appsettings I used in my application.

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

Here "myDb" , "myUserId" , "myPass" is equivalent to actual database name ,actual user id they provided and actual password that i set when creating database in the hosting server.

Please help me to connect the database in 1&1 ionos hosting server by suggesting write connection string or guiding me what else I need to do or please share if anyone has example connection string for connecting to SQL Server database from asp.net mvc or asp.net web api or asp.net core application hosted in 1&1 Ionos windows server.

At last it worked,here is my working appsettings. Hopefully it will help you guys.

  "AppSettings": {
    "Secret": "bla bla bla"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "CustomPosConnection": "Data Source=db784146660.hosting-data.io,1433;Initial Catalog=myDb;Integrated Security=False;User Id=myUserId;Password=myPass;MultipleActiveResultSets=True;"
  }
}

Here "myDb" , "myUserId" , "myPass" is equivalent to actual database name ,actual user id they provided and actual password that i set when creating database in the hosting server.

It has been hard to figure out the connection string for .Net core shared hosting. My provider AspHostPortal worded with

"DefaultConnection": "Server=ipAddress\\SQL2017,782; Database=DatabaseFileName_without.mdf;Integrated Security=False; User Id=userName;Pwd=passWord;MultipleActiveResultSets=true"

Integrated Security=True may not work if SSL is not enabled on server

I am not sure why Microsoft change the format from Web.Config format to confuse everybody.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM