Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Connection strings going from local drive to a network dri..

 
   Database Help (Home) -> Programming RSS
Next:  Jet uses Yellowfin for Location Intelligence  
Author Message
RayLopez99

External


Since: Feb 08, 2010
Posts: 4



(Msg. 1) Posted: Mon Feb 08, 2010 5:47 am
Post subject: Connection strings going from local drive to a network drive using
Archived from groups: microsoft>public>sqlserver>programming (more info?)

Using the Wizards (drag and drop from toolbox) in Visual Studio 2008,
does anybody know a quick way to repoint or redo the connection string
so that it points to the right database?

Here's the problem:

Say you have a database in c:\Directory1\NORTHWND.MDF.

Now your connection string points to it. Everything works fine, the
program (a web app using ASP.NET) works fine.

You move the database to c:\Directory2\NORTHWND.MDF

But changing globally the connection strings from "Directory1" to
"Directory2" (doing a global search and replace) gives a runtime error
('database could not be opened..." etc).

So I guess I have to drag and drop connection strings 'by hand' and
restart all over again, which is tedious since the Wizard also asks
you to redo the SQL query associated with the connection string...

I'm confident after a few hours I'll get it to work, but is there a
quicker way and does this problem ring a bell?

Also, as a bonus followup question: suppose I get this program to
work on my local drive. Now I want to make the database reside on a
network drive. The network is supported by an IT guy who is not that
knowledgeable about databases. What's the minimum I need to tell him,
and again, do I need to replace and redo "the hard way" all connection
strings? What would be the path I use, or is the program smart enough
to figure out to search the entire LAN?

This is a web app, using Visual Web Developer under Visual Studio 2008
SP1 and SQL Server Express 2005.

RL

 >> Stay informed about: Connection strings going from local drive to a network dri.. 
Back to top
Login to vote
RayLopez99

External


Since: Feb 08, 2010
Posts: 4



(Msg. 2) Posted: Mon Feb 08, 2010 7:49 am
Post subject: Re: Connection strings going from local drive to a network drive [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 8, 5:47 am, RayLopez99 wrote:

> Also, as a bonus followup question:  suppose I get this program to
> work on my local drive.  Now I want to make the database reside on a
> network drive.  The network is supported by an IT guy who is not that
> knowledgeable about databases.  What's the minimum I need to tell him,
> and again, do I need to replace and redo "the hard way" all connection
> strings?  What would be the path I use, or is the program smart enough
> to figure out to search the entire LAN?
>
> This is a web app, using Visual Web Developer under Visual Studio 2008
> SP1 and SQL Server Express 2005.
>

I have a partial answer to this last question, from a book:
"Generally, a better option is to include the local database files in
the directory structure of your web project--specifically, putting the
database files in the App_Data of your web application"--that way your
code can access this database easily.

RL

 >> Stay informed about: Connection strings going from local drive to a network dri.. 
Back to top
Login to vote
RayLopez99

External


Since: Feb 08, 2010
Posts: 4



(Msg. 3) Posted: Mon Feb 08, 2010 4:49 pm
Post subject: Re: Connection strings going from local drive to a network drive [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 8, 7:49 am, RayLopez99 wrote:

I figured out my problems, and just to complete this thread here are
the solutions:

1) you have to install SQL Server 2008 when working with Visual Studio
2008. That solved most of the problem #1.

2) as a bonus, I figured out a trick on how to use a relative path to
store your database, so that deploying it in a LAN is easy. From this
blog post (and it is undocumented):
http://www.develop-one.net/blog/2006/09/05/RelativePathInWebApplicatio...nnectio

The trick is this: using the term "=|DataDirectory|" will reference
the directory "App_Data" found in ASP.NET projects (and the
conventional place to put data).

So, suppose your database was called "myDatabase1", and your
Web.config file had this entry:

<connectionStrings>
<add name="myDataBaseConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename="C:\HardCodedDirectory
\myDataBase1.mdf";Integrated Security=True;Connect
Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>



you would copy the database into your \App_Data folder found in the
app's root directory, then substitute this connection string (in
Web.config) to reference the database, which now resides under the
app's root directory, in \App_Data. Problem #2 solved, since no need
for an absolute file path, which is tricky in a LAN:



<connectionStrings>
<add name="myDataBaseConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename="|DataDirectory|
myDataBase1.mdf";Integrated Security=True;Connect Timeout=30;User
Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>


RL
 >> Stay informed about: Connection strings going from local drive to a network dri.. 
Back to top
Login to vote
Jay

External


Since: Aug 26, 2007
Posts: 17



(Msg. 4) Posted: Mon Feb 08, 2010 5:25 pm
Post subject: Re: Connection strings going from local drive to a network drive using Wizards in Visual Web Developer? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> 2) as a bonus, I figured out a trick on how to use a relative path to
> store your database, so that deploying it in a LAN is easy. From this
> blog post (and it is undocumented):
> http://www.develop-one.net/blog/2006/09/05/RelativePathInWebApplicatio...nnectio
>
> The trick is this: using the term "=|DataDirectory|" will reference
> the directory "App_Data" found in ASP.NET projects (and the
> conventional place to put data).

I was of the impression that programs dealt with things like this by having
an include file (or whatever it's called in your language) that had platform
specific information in it, like a .ini file, or the registry entries.
 >> Stay informed about: Connection strings going from local drive to a network dri.. 
Back to top
Login to vote
RayLopez99

External


Since: Feb 08, 2010
Posts: 4



(Msg. 5) Posted: Wed Feb 10, 2010 7:16 am
Post subject: Re: Connection strings going from local drive to a network drive [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 8, 5:25 pm, "Jay" wrote:
> > 2) as a bonus, I figured out a trick on how to use a relative path to
> > store your database, so that deploying it in a LAN is easy. From this
> > blog post (and it is undocumented):
> >http://www.develop-one.net/blog/2006/09/05/RelativePathInWebApplicati...
>
> > The trick is this:  using the term "=|DataDirectory|" will reference
> > the directory "App_Data" found in ASP.NET projects (and the
> > conventional place to put data).
>
> I was of the impression that programs dealt with things like this by having
> an include file (or whatever it's called in your language) that had platform
> specific information in it, like a .ini file, or the registry entries.

Web.config is the file this string appears in, so it's similar to what
you have in mind.

RL
 >> Stay informed about: Connection strings going from local drive to a network dri.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Can I back up a remote db to a local drive? - When I go into the backup dialog, I can browse the server's file system for a place to put a backup file. Is there a way to backup a database to my local machine?

cmdshell copy file to network drive - Hi, I want copy xls file to Network drive. EXEC MASTER..xp_Cmdshell 'copy "c:\connect\einvoice.xls" "\\Server\C$\test\"' I generated following message Logon failure: unknown user name or bad password. Where should i specify user name ...

Restore over the network vs from local disk - 1- Last week I restored a 175GB .BAK file which creates a db of 205GB size using UNC (\\IP\Drive$\Backup\Filename.bak) where Drive$ is a resource of a SAN. The restore took 5.5 hours with 9.096 MB/sec. 2- Now I am currently restoring a more recen...

Storing Data on Local terminal in a LAN Based Network - Hi Everyone I need your help urgantly. i have a DB shared on a LAN. I have a table that has entries about the companies and another table that has the enteries of the employees working in my organization. So two tables one has info about other companies....

unable to debug SP call made on a local sql instance to an.. - Hello, I have a VB.Net app (using ADO.Net) which calls a stored procedure on a local sql server instance, which, in turn, calls another SP via a linked server which points to yet another local sql server instance. I am able to debug everything excep...
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]