Monday, March 19, 2012

Connecting to MDF file over Workgroup

Hi

I've build a client management (Windows) application in VS2005 which works fine on the local development machine but falls over when trying to connect to the SQL Server Express file located on a second machine on the same Workgroup. Several of the apllications will connect to the database file from networked computers.

The error I get when testing the connection or trying to connect via the App is:

-------------------
The file "Z:\BushBreaks.MDF" is on a network path that is not supported for database files.
An attempt to attach and auto-named database for file z:\bushbreaks.mdf failed. A database with the same name exists, or specified file cannot be opened or it is on a UNC share.
-------------------

How can I configure this database and/or connection to be able to allow connections to the MDF file? Please note that security is not an issue if that is at all relevant.

Many Thanks
John

Current you can't use remote database file in your SQL connection. Here is a instruction about AttachDBFileName property in connection string from MSDN:

The name of the primary database file, including the full path name of an attachable database. The path may be absolute or relative by using the DataDirectory substitution string. If DataDirectory is used, the database file must exist within a subdirectory of the directory pointed to by the substitution string.

Note:

Remote server, HTTP, and UNC path names are not supported.

For more information, you can refer to:

http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx

No comments:

Post a Comment