Default database location .net

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Default database location .net

Post by agibsonsw »

Hello. (VB 2008 Express)
I have a question concerning the following code:

myConnection = New SqlConnection("server=(localhost);uid=sa;pwd=;database=pubs")

Where is the default location for the database set? I could put the full path in the statement, but wonder if I can set a default path instead?

Thanks, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78398
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Default database location .net

Post by HansV »

I think you should use either server=(local) or server=localhost (without parentheses). This uses the SQL Server engine on your machine; it "knows" where the databases are, you don't have to specify a path.
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Default database location .net

Post by agibsonsw »

Thank you, I'll try this.
I notice that the Sql Server has a Data Path which is the same as the Install Path, but hopefully it will find my database (in a different path).
Ta, Andy.

Not quite there yet.
I'm using SQL Server Express; did I need to type something other than localhost?
Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Default database location .net

Post by agibsonsw »

.. don't worry, I've got it running. (I added a data source using the visual tools and 'borrowed' the connection string for my code.)
Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.