Solved

Developing locally and deploying remotely - database access

Posted on 2008-10-09
3
290 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now