本文介绍了oledb通过网络的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下连接字符串可能是什么问题

What can be the problem with following connectionStrings

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.14\SmoeSharedFolder\test.mdb;";

当我在该计算机上访问数据库 otherCP

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;";

我也可以使用此路径从其他PC打开文本文件。这说明该路径应该有效

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?

推荐答案

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;";

两个字符串均有效,可以从网络PC访问数据库。如果您的数据库文件存在于您具有权限 =>的文件夹中,则该文件夹位于共享文件夹中。 仅在您具有写权限的情况下,您才可以写(更新/插入)

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.

我遇到错误无法打开指定的文件。因为我在使用 otherPCName 和IP 192.168.14 时都遇到问题。 (对于其他pcname,我使用的是sampc,但它是sam-pc)。

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).

这篇关于oledb通过网络的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 05:22