Saturday, February 25, 2012

Connecting SQL SERVER 2005 EXPRESS EDITION using Server Explorer

Hi all.

I use Visual Studio .NET 2002 and SQL Server 2005 Express Edition as database.

I try to connect to database using server explorer.

Test connection is OK. When I done with it and click OK, the message prompt that "Unable to connect to database".

So, is it impossible to connect SQL Server 2005 Express Edition using the server explorer?

But, the connection is ok when I connect through code cause I can retrieve and update database.

Hi azrina,

From your description I would guess, are you connecting to your sql express database both from your code and server explorer? and besides, you choose "auto attached" for your database file(.mdf), am I right?

If yes, i would say, well, since sql express use "custom instance" and there is a basic principle that one mdf file cannot be bound to more than 1 instance at the same time, so, if you are accessing your database file from your code, that particular file(say, dbname.mdf file) would be attached to your sql express custom instance. While if now you are connecting to the sql express again from server explorer, probably you will be not able to access that database file --most possibly you will get a "the database file has been already been attached" error.

Anyway, that's just my assumption and I use visual studio 2005 instead of vs.net 2002. And by the way, I've also encountered some kinds of troubles when connecting to my database from server explored--which sometimes I find is hard to descibe and explain.

Just hope my suggestion could help

|||Actually, what I am trying to do is to add database to the server explorer. As I want to use the DataSet, I can just drag and drop the sqlconnection and etc coz vs studio.net tools support the data access using data set. But, I think this version of my Visual Studio .Net does not support the SQL Server 2005 Express Edition. What can I do now is just do the data access thru code and not using the tools provided.

No comments:

Post a Comment