[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Developing locally and deploying remotely - database access

Posted on 2008-10-09
3
Medium Priority
?
299 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
[X]
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
  • 2
3 Comments
 
LVL 32

Assisted Solution

by:Daniel Wilson
Daniel Wilson earned 1200 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 1200 total points
ID: 22677558
0
 

Accepted Solution

by:
ghopkins66 earned 800 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Viewers will learn how the fundamental information of how to create a table.
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.
Suggested Courses

650 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