Then i create a database account on the remote host, uploaded my database backup file, and run restore. please i want know how to configure web.config to use this database on my remote server.
You need to get the connection string for your production database, and in the web.config file in the deployed site replace the SQL Express connection string with the production connection string. If your project is a web application project (rather than
a web site project), the easiest way to change the connection string in the web.config file in the deployed site is to use a web.config transformation file. See this MSDN how-to doc and this ASP.NET site tutorial:
I did what you told me and this the error am getting
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
abfrank
Member
10 Points
20 Posts
database cant work on remote server
Feb 28, 2012 03:02 PM|LINK
I designed an application with a database name RoyalHome, When i run it my localhost it worked, but after i uploaded to a remote machine
and run it, i get an error message UNABLE TO CONNECT connectionString FOR OBJECT web.config.
The database i am using is MS SQL server,
Below is what i have in my web.cofig
<connectionStrings>
<add name="RoyalHomeConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\RoyalHome.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Then i create a database account on the remote host, uploaded my database backup file, and run restore. please i want know how to configure web.config to use this database on my remote server.
tdykstra
Contributor
4444 Points
621 Posts
Microsoft
Moderator
Re: database cant work on remote server
Feb 28, 2012 03:20 PM|LINK
You need to get the connection string for your production database, and in the web.config file in the deployed site replace the SQL Express connection string with the production connection string. If your project is a web application project (rather than a web site project), the easiest way to change the connection string in the web.config file in the deployed site is to use a web.config transformation file. See this MSDN how-to doc and this ASP.NET site tutorial:
http://msdn.microsoft.com/en-us/library/dd465318.aspx
http://www.asp.net/mvc/tutorials/deployment-to-a-hosting-provider/deployment-to-a-hosting-provider-web-config-file-transformations-3-of-12
For web site projects, you have to update the deployed web.config file manually.
asyed4u
Participant
1307 Points
268 Posts
Re: database cant work on remote server
Feb 28, 2012 03:20 PM|LINK
hi,
chenage ur connection string (if ur restore in sqlserver )
<connectionStrings>
<add name="RoyalHomeConnectionString"
connectionString="Data Source=YOURremoteserverName\YourSqlServerInstanceName\;
user id=UR SQL USERNAME; password=UR PASSWORD; Integrated Security=false;Connect Timeout=30;"
providerName="System.Data.SqlClient" />
</connectionStrings>]]
..............
if ur database not in sqlserver... ie Within project then
remove the ......... user instance=true
abfrank
Member
10 Points
20 Posts
Re: database cant work on remote server
Feb 28, 2012 03:25 PM|LINK
Thanks for your reply, but please what do mean by YourSqlServerInstanceName.
asyed4u
Participant
1307 Points
268 Posts
Re: database cant work on remote server
Feb 28, 2012 03:29 PM|LINK
ie,, Optional one
if remote machine , may have more then one SQL SERVICE..
like ... REMOTE\SQLEXPRESS
REMOTE\SQLSERVER08
REMOTE\SQLSERVER10,,,,
if ur REMOTE only one or ... u r restored in REMOTE means,,,
u can access as ..simply REMOTE
abfrank
Member
10 Points
20 Posts
Re: database cant work on remote server
Feb 28, 2012 03:35 PM|LINK
am glad for your help
asyed4u but please explain further
abfrank
Member
10 Points
20 Posts
Re: database cant work on remote server
Feb 28, 2012 03:46 PM|LINK
I did what you told me and this the error am getting
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
asyed4u
Participant
1307 Points
268 Posts
Re: database cant work on remote server
Feb 28, 2012 03:47 PM|LINK
<connectionStrings>
<add
name="NorthwindConnectionString"
connectionString="Data Source=serverName;
Initial Catalog=Northwind;Persist Security Info=True;
User ID=userName;
Password=password"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
..please ensure the servername as Per ur server,,
1) u r database in sqlserver ??
2) u can directly through sqlserver via sqlstudiomanagment client
ok please refer http://www.marten-online.com/net/storing-database-connection-string-in-webconfig.html
http://stackoverflow.com/questions/7687930/db-connection-string-in-web-config-to-use-attached-mdf-database-wont-work