问题
What can be the problem with following connectionStrings
string constr = @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=\\otherPCName\SmoeSharedFolder\test.mdb;";
Or
string constr = @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=\\192.168.14\SmoeSharedFolder\test.mdb;";
No Problem with following connection String, when i access database on that PC otherCP
string constr = @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=D:\SmoeSharedFolder\test.mdb;";
Also I can open a text file from other PC using this path. This tells the path should be valid
\\otherPCName\SmoeSharedFolder\hi.txt
I have seen connection strings for network so I think they should work but how?
回答1:
string constr = @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=\\otherPCName\SmoeSharedFolder\test.mdb;";
string constr = @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=\\192.168.1.14\SmoeSharedFolder\test.mdb;";
Both strings are valid to access database from a network PC. If your database file exists in a folder to which you have permissions => Exists in a Shared folder. You will be able to write (update/insert) only if you have write permissions as well.
I was getting error specified file cannot be opened
. Because I had problem both in using otherPCName
and IP 192.168.14
. (For otherpcname I was using sampc but it was sam-pc).
来源:https://stackoverflow.com/questions/13457608/connection-string-over-network-for-oledb