Miguel A. Delgado Miguel A. Delgado - 1 year ago 76
C# Question

Connecting to SQL Server Database using a Hosted Web Application

I have created a .net web application using c# that inserts,updates, and deletes data from an sql server database. I have tested it using my localhost and it works fine. Now I would like to publish this application on a hosted site.

My question is, does the database need to be on the same server/host that the application is in for it to connect? Does anyone have any tips on how to implement this? Thanks in advanced!

Answer Source

If your Question is 'How to connect database present on another server', then you have to Add IP address of it in the Web.config file as:

    <add name="myConnectionString" connectionString="data source=myserver\SQLEXPRESS;initial catalog=myDatabase;uid=myUserName;password=myPassword;" />

data source can be IP ADDRESS or PC NAME, where Database is stored.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download