Connection string question

T

Tony Girgenti

Hello.

Developing a web site in VS2005, SP1, VB, .NET 2.0, ASP.NET 2.0, SQL Server
Express on XP Pro,
SP2.

In my web.config file, if my connection string looks like this:
"connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename="C:\Documents and
Settings\Administrator\My Documents\Visual Studio
2005\WebSites\CoyneWebSite\App_Data\CoyneWebDatabase.mdf";Integrated
Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient"/>"

Shouldn't i be able to change it to "~/App_Data/CoyneWebDatabase.mdf"?

So that when i upload my website to my host it looks for "App_Data" off of
the root of the website.

Any help would be gratefully appreciated.

Thanks,
Tony
 
W

William \(Bill\) Vaughn

Ah, I'm a bit confused. If this is a web site, it's not really a "client"
application... or is it?
Your connection string would be more suitable for a Windows Forms
application access a local (user) instance of SQL Express--not for a web
site.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 
A

AMDRIT

Perhaps when he is doing development, he develops against a local DB
(SQLExpress), while in production he connects to a production server. I
think his question is more along the lines of, "How do I set my connection
information once it is in production and where is the MDF file supposed to
live."

I don't know the answer, I have never connected to an MDF file and am not
familiar with doing so. I always connect to a SQL server and so my
connnectionstring is more on the lines of "server=myserver; db=mydatabase;
uid=myusername; pwd=mypassword;"
 
T

Tony Girgenti

Hello Bill.

This is a web site that i created in VS2005 by selecting File/New Web Site,
then selecting ASP.NET Web Site.

I don't know how that connection string got the way it is.

Thanks,
Tony
 
T

Tony Girgenti

Hello Francesco.

This allowed me to continue with my development without errors.

I will see what happens when i upload my site.

Thanks,
Tony
 
W

William \(Bill\) Vaughn

Sigh. Well, it's just wrong for use with a web site. Without going into a
LONG explanation, the User Instance and AttachDBFilename options don't make
sense for a web site for a number of reasons. It might make sense if you
were creating a single-user ASP applications (which is very strange IMHO),
but for a Web site... not. The ConnectionString you use for a web site
typically addresses a specific server\instance and use SSPI
security--without the User Instance or AttachDBFilename--that's because the
database has already been attached to the SQL Server (even Express) prior to
execution.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top