Connecting to a PC on LAN using \\Server\c\...

I have tried to connect to the remote computer using this

string = 'Server=tcp:SERVER,1433;Database=TBSDB.mdf;Integrated Security=True;Network Library=dbmssocn;Connect Timeout=30;User Instance=True'

Then system tcp connection enabled and firewall disabled. The computer name is SERVER where TBSDB.mdf is the database file located in the App directory of the C:\ of the remote computer.

"I want to connect to a database on another PC connected via LAN. I am able to use the sql server db with string like C:\Users... but i cannot connect using string like (\\Server\c\user...) I tried to move the db file to My Documents, still i get this error.

I get the following error message:

An attempt to attach an auto-names database for file
(\\SERVER\Users\Jeswills\Documents\TBSDB.mdf) failed. A database with
the same name exists, or specified file cannot be opened, or it is
located on UNC share.

I hope i asked the question correctly

1 answer

It seems attaching to a file on an UNC path is not allowed. An UNC path is on the network using this format '\\server\share\folder' compared to a local path 'C:\folder'.

Some info about AttachDBFilename from this article.

The name of the primary database file, including the full path name of
an attachable database. AttachDBFilename is only supported for primary
data files with an .mdf extension. The attachment will fail if the
primary data file is read-only. 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 that remote servers, HTTP, and UNC (\\server\sharename\folder)
path names are not supported
.

The database name must be specified with the keyword 'database' (or
one of its aliases) as in the following:
"AttachDbFileName=|DataDirectory|\data\YourDB.mdf;integrated
security=true;database=YourDatabase". An error will be generated if a
log file exists in the same directory as the data file and the
'database' keyword is used when attaching the primary data file. In
this case, remove the log file. Once the database is attached, a new
log file will be automatically generated based on the physical path.