localdb connection string for hosting server in ASP.Net

Last Reply 2 months ago By dharmendr

Posted 2 months ago

Hello forum,

When hosting a website online with database, what will be the connection string? Because my connection string is:

SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Dataregister.mdf;Integrated Security=True");

The above connection string is for local DB, how will this connection string be online?

And will the connection string be in the .aspx.cs file (that is code page) or will it be inside the web.config file?

Also, will the command line, SqlDataAdapter and DataSet remain the same as shown below? or will there be changed to something different?

SqlCommand cmd = new SqlCommand();
SqlDataAdapter sda = new SqlDataAdapter();
DataSet ds = new DataSet();

Please I need guidance on this. Thank you

You are viewing reply posted by: dharmendr 2 months ago.
Posted 2 months ago

Hi George616,

If your hosting package supports the use of SQL Server, they should provide you with the relevant connection details.

Refer below links.

https://forums.asp.net/t/2013428.aspx?localdb+connection+string+for+host