Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server or SQL Server database file?

Status
Not open for further replies.

ZmrAbdulla

Technical User
Apr 22, 2003
4,364
AE
Using
SQL Server 2005 Express
Visual Web Developer 2005 Express
=============================

I have created some aspx pages to use them in a network in our office. I need to use SQL Server as data provider. I am working from a machine where "SQL Server Express" installed. Later I need to transfer these files to a server from where everyone can access the pages.

I can select "SQL Server" or "SQL Server database file" when I choose the datasource of my pages. If I choose a file then the connection string will be like "C:\MyFolder\MyDb.mdf". How can I change the connection automatically when I transfer these files to a common server? What are the steps I need to take for the process? We have SQL Server running in our office.

Any pointers, reading or tips will be really appreciated.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Rather than hard code the connection string, you would typically store it in the appsettings section of the web.config file and then retrieve it with the ConfigurationManager class. e.g
Code:
<appSettings>
  <add key="myDatabaseConnectionString" value="connection string goes here" />
</appSettings>
Code:
ConfigurationManager.AppSettings("myDatabaseConnectionString")




____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks ca8msm for the reply.

It is there in the "Web.config" file.
Code:
	<connectionStrings>
  <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\AB.mdf;Integrated Security=True;User Instance=True"
   providerName="System.Data.SqlClient" />
  <add name="ABConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Intranet\App_Data\AB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>

I think I need to change "SQLEXPRESS" to my "SERVERNAME" and the "folder map" in the connectionstring when I transfer the files to the server
Am I right?

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Yes in the scenario above, you just need to change the ConnectionString property to point at the new server.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks...
...and will be back with more questions[wink]


________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top