Connecting - (local)\SQLEXPRESS

M

Miro

Recently I had to switch out my XP machine with vb.2005 express and SQL
Express ( the computer died )
to vb.2008 Express with SQL Express and Vista.

The wierd part is, my microsoft book stopped working with the connection
strings from the chapters from the book.

By default this should work:
sqlProducts.ConnectionString = "Data Source=(local)\SQLEXPRESS;Initial
Catalog=AdoStepByStep;Integrated Security=True"

But it fails until I change the connection string to this:

Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Microsoft Press\ADO.NET 2.0
Step by Step\SampleDBs\AdoStepByStep_Data.MDF";Integrated
Security=True;Connect Timeout=30;User Instance=True


The book also comes with an exe that runs and says it attaches the database.
"AdoStepByStep database should be attached to (local)\SQLEXPRESS"
that should allow all the chapters to work.

Where can I go to check this configuration of where it attached.

Any help would be appreciated.

So far I have been opening up the chapters project and have been running
around everywhere changing the connection string, but I know there has to be
a setting somewhere that Vista or 2008 has changed.

Miro
 
N

Norman Yuan

Miro said:
Recently I had to switch out my XP machine with vb.2005 express and SQL
Express ( the computer died )
to vb.2008 Express with SQL Express and Vista.

The wierd part is, my microsoft book stopped working with the connection
strings from the chapters from the book.

By default this should work:
sqlProducts.ConnectionString = "Data Source=(local)\SQLEXPRESS;Initial
Catalog=AdoStepByStep;Integrated Security=True"


It should still work as long as your windows user account is mapped to a SQL
Server login and is given appropriate permission. Prior to VISTA, if your
windows account is local admin, you automatically gain full access to the
SQL Server. With VISTA, you need to explicitly make a windows user account
being able to access SQL Server. You need a bit more study on SQL Server
security (how to access SQL Server).

But it fails until I change the connection string to this:

Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Microsoft Press\ADO.NET 2.0
Step by Step\SampleDBs\AdoStepByStep_Data.MDF";Integrated
Security=True;Connect Timeout=30;User Instance=True


Keyword here is "USER INSTANCE=True". The "USER INSTANCE" feature is only
available to SQL Server Express. That means the attached database is
onlyaccessible to current Windows user. If your use of SQL Server Express is
only limited to going through the book, then that is fine. If you ever want
to do more programming projects that will use SQL Server/Express, then you
need more thorough understanding on SQL Server, and be very careful of using
SQL Server Express' USER INSTANCE (meaning not using it until you really
know what it is).

The book also comes with an exe that runs and says it attaches the
database.
"AdoStepByStep database should be attached to (local)\SQLEXPRESS"
that should allow all the chapters to work.

Where can I go to check this configuration of where it attached.


If it is "USER INSTANCE", it is somewhere underneath C:\Users\[Your user
name]\...

Any help would be appreciated.

So far I have been opening up the chapters project and have been running
around everywhere changing the connection string, but I know there has to
be a setting somewhere that Vista or 2008 has changed.


It is SQL Server/Express configuration and has little to do with VS2008.
 
M

Miro

Thank you,

You gave me the information I needed.
You are right about learning sql server, but I tried the first time going to
fast and started asking way too many questions on the board here. So The
sql server lessons will come - once I understand how to get data from it.
Taking it slow, step by step from the book.

For anyone who reads this - here is what I did.
I uninstalled my sql 2005 express ( i didnt know if i had the sp2 or not ),
and re-installed it.
I also uninstalled it for the reason that I did not have a "SQL Server
Management Studio Express"

Once I re-installed this, then I tried to follow these instructions:
http://blogs.msdn.com/sqlexpress/ar...ta-aka-dealing-with-user-account-control.aspx

But I ran it without "Right Clicking" and wasnt able to attache the
database. ( That was me - rtfs problem )

What I did do, is i did go to the exe program taht comes with the book to
automatically attach the db to sql server and ran it - it didnt work either.
But Right clicking on the exe and running it as administrator - did work.

Then going back to the instructions from the link, and running "Server
Management Studio Express" as admin, I was able to attach and detach the
same database.

Im not sure what I had installed earlier, but it was probably the simple sql
express 2005 instead of the one with the extra features.

Thank you for all your help Norman.

Just some vista growing pains as well :) ( Running things as
administrator )


Miro





Norman Yuan said:
Miro said:
Recently I had to switch out my XP machine with vb.2005 express and SQL
Express ( the computer died )
to vb.2008 Express with SQL Express and Vista.

The wierd part is, my microsoft book stopped working with the connection
strings from the chapters from the book.

By default this should work:
sqlProducts.ConnectionString = "Data Source=(local)\SQLEXPRESS;Initial
Catalog=AdoStepByStep;Integrated Security=True"


It should still work as long as your windows user account is mapped to a
SQL Server login and is given appropriate permission. Prior to VISTA, if
your windows account is local admin, you automatically gain full access to
the SQL Server. With VISTA, you need to explicitly make a windows user
account being able to access SQL Server. You need a bit more study on SQL
Server security (how to access SQL Server).

But it fails until I change the connection string to this:

Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Microsoft Press\ADO.NET 2.0
Step by Step\SampleDBs\AdoStepByStep_Data.MDF";Integrated
Security=True;Connect Timeout=30;User Instance=True


Keyword here is "USER INSTANCE=True". The "USER INSTANCE" feature is only
available to SQL Server Express. That means the attached database is
onlyaccessible to current Windows user. If your use of SQL Server Express
is only limited to going through the book, then that is fine. If you ever
want to do more programming projects that will use SQL Server/Express,
then you need more thorough understanding on SQL Server, and be very
careful of using SQL Server Express' USER INSTANCE (meaning not using it
until you really know what it is).

The book also comes with an exe that runs and says it attaches the
database.
"AdoStepByStep database should be attached to (local)\SQLEXPRESS"
that should allow all the chapters to work.

Where can I go to check this configuration of where it attached.


If it is "USER INSTANCE", it is somewhere underneath C:\Users\[Your user
name]\...

Any help would be appreciated.

So far I have been opening up the chapters project and have been running
around everywhere changing the connection string, but I know there has to
be a setting somewhere that Vista or 2008 has changed.


It is SQL Server/Express configuration and has little to do with VS2008.


 

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