Connection String over network for oledb

蹲街弑〆低调 提交于 2019-12-12 04:46:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!