Friday, February 10, 2012

Connecting to SQL server 2005 express in LAN Using C# express

I tried to connect to SQL server 2005 express in LAN Using C# express

I got this msg

the file \\blablabla\\blablabla.mdf is on a network path is not supported for database file.An Attempt to attach an auto-named database for file \\blablabla\blablabla.mdf failed. a database with same name is exist, or specified file can not be opened, or its located on UNC share.

Is that mean :

I can not connect to SQL server remotly using express edition of C#

SQL server dosen't support connection in LAN

I tried to set all options like enable TCP IP connection and networks

by the way

The data has unquie name and it is located in shared folder and I can easly to connect to database like access with no problem

I will be thankful if you can help me

With the Express Edition of SQL Server you can't connect to databases over LAN. Only local database are supported.|||

Firstly Thank you very much to help me..

I read in features of sql express we can make the data in the server and shares the information with others clients. Also because sql express support web devlopment ASP that's mean the databse should be shared in the web ,, All that's mean sql server support to be in local area network !

please be sure, because I think visual C# express dosnt support client server database not sql server !

Im waiting for your comments :-)

|||I am able to connect to an instance of SQL Server Express from seperate machines on the same network using Server Management Studio Express CTP. So it appears access to SQL Server Express does work on a LAN.|||

"a database with same name is exist, or specified file can not be opened, or its located on UNC share"

Is one of these three your problem? Is it a file shared on a network? Is the path+filename correct? Does a database with the same name already exists?

Let's rule those out first.

|||I have encountered the same problem attempting to create a .mdf database file on a network drive. The Knowledge Base, Article ID: 304261, states that if you turn Trace flag 1807 on that you can connect to a mapped or UNC network drive. But it doesn't work, as recommended, "http://msdn2.microsoft.com/en-us/library/ms176061.aspx, using the SQL statement "Create Database MyDB ON Primary "S:\blah\blah".
It returns the error "Msg 5133, Level 16, State 1, Line 2
Directory lookup for the file "S:\colorlab\stores\_MouerMichael\TestingSQLX\MyLoc.mdf" failed with the operating system error 3(The system cannot find the path specified.)."

If I use the path "C:\blah\blah" - no problem.

Now I know the path is there and the OS finds it OK using other programs.

My goal is to move from a MSAccess DB on a network drive to a SQLExpress DB on a network drive.|||

Experiencing the same issue. I am also wishing to migrate from MSDE.

Using Microsoft SQL Server Management Studio Express I can create and populate a DB.

I wish to connect to it from VB express. However, I receive the error message that was listed in the first post in this thread.

My goal is to have SQL Server host a DB on a small network, allowing several workstations to access it concurrently.

How does one, or can one, share a DB using SQL Server Express?

Thanks in advance,

Lance

|||

I have exactly the same problem and still no answer.

Everything can be done using Microsoft SQL Server Management Studio Express

with a local or remote connection, but I can't connect to a database to create a mdf or read, populate (...) an existing database with visual studio c# express.

There is only one way to connect to an SQL server with express studios (c#, VB ...) and it's by selecting an existing mdf file on remote server and it doesn't work at all.

If someone find a solution please post.

Thanks, vax

|||

I am having the same problem. I tried setting trace flag 1807 like this:

dbcc traceon (1807,-1)

GO

But the management studio still doesn't seem to like my path (F:\) which is mapped to an NFS share. This is with SQL Server 2005 Enterprise Version.

Thanks
Eno

|||Here is what I have discovered to work.

1) Open the SQL Server Management Studio Express CTP and create a database.

2) Detach the database

3) Exit

4) Go to your language IDE of choice VB, C#, etc.

5) Create a new connection source to the DB you just created.

6) Go to the Solution Explorer and change the property "Copy to Output Directory" to 'Copy if newer'.

7) Close IDE

8) Open the SQL Server Management Studio Express CTP and reattach to the DB.

For me at least, all is well.

Lance|||

Ok, the pieces of the puzzle are finally complete. Here is what I did:

1. used the traceon flag as mentioned above

2. gave the full server name (i.e. \\server\share) and NOT the path where the share is mapped (i.e. DO NOT USE F:\share).

I got a further complication, because apparently SQL server had trouble finding the block size used on that NFS server. To deal with that I created the db on local disk first, then used DETACH/ATTACH to move the database to the NFS share. Kind of a long process but it worked. This is along the lines of the comment posted on detach/attach in this same thread chain.

No comments:

Post a Comment