Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Developing locally and deploying remotely - database access

Posted on 2008-10-09
3
293 Views
Last Modified: 2010-04-14
Hi Folks,

I'm pretty new to .Net and am having some issues moving from classic ASP to ASP.Net.  The situation I have is as follows.

I've a domain hosted by 1and1 which includes an MS SQL database.  One of the issues I have is that you cannot link to the DB with a locally installed Enterprise Manager/SSMS, so I'm unable to write a client app that accesses my data on the host.  As such, I need to make a web app that will allow me to carry this out.

I could use ASP but think I need to update my skills somewhat but unfortunately, amongst the multitude of guides and articles I've not found anything that suggests a solution to this specific problem.  Essentially where previously I would make a local copy of the database, develop for that and then change my connection string when uploading I don't know whether that's a) possible or b) appropriate when using .Net.

So, at last, my question is.  If I develop a web app locally can I change the connection string (or equivalent) after deployment on the application server so that it points to the hosted database, and if so, how?

I'd really appreciate it if someone could help or point me in the correct direction.

Oh, and I'm using VS2005 with SQL 2005, and would prefer any code suggestions in VB.Net.

Later,

Jes
0
Comment
Question by:JesGoth
  • 2
3 Comments
 
LVL 32

Assisted Solution

by:Daniel Wilson
Daniel Wilson earned 300 total points
ID: 22677555
>>If I develop a web app locally can I change the connection string (or equivalent) after deployment on the application server so that it points to the hosted database, and if so, how?

Your connection string(s) should be going in your web.config file.  As such, changing it/them after deployment is simple -- just deploy a modified web.config.
0
 
LVL 32

Assisted Solution

by:Daniel Wilson
Daniel Wilson earned 300 total points
ID: 22677558
0
 

Accepted Solution

by:
ghopkins66 earned 200 total points
ID: 22677594
Hello,

The web.config file in the root of your asp.net application is an XML file containing configuration aspects for your website. When you connect to a local (SQL Express) database it will create a ConnectionString in the web.config. Providing your database structure is the same in the remote database as it is locally then you can change the connection string in the web.config to point to your remote database with the necessary authentication details.

Attached a code snippet of Local (SQL Express) and Remote connection strings in web.config.

Regards,
Gareth
<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
	<connectionStrings>
<!--Local Example-->
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
   providerName="System.Data.SqlClient" />
<!--Remote Example-->
		<add name="ConnectionString" connectionString="Data Source=ServerIpOrDomainHere;Initial Catalog=DatabaseNameHere;Persist Security Info=True;User ID=DatabaseUserHere;Password=DatabasePasswordHere;" providerName="System.Data.SqlClient"/>
	</connectionStrings>
</configuration>

Open in new window

0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question