连接到 LAN 网络位置上的数据库 [英] Connecting to a database on a LAN network location

查看:65
本文介绍了连接到 LAN 网络位置上的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我想通过网络访问文件.我目前正在使用此连接字符串.

I have an application that I want to access a file over a network. I am currently using this connection string.

string myconnectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\" + PCName + "\\datafolder\\data.mdb";

PC 名称是我在网络上看到的计算机的名称:

The Pc name is the name of well the computer as seen on the network I get that using:

Dll Netapi32然而,虽然我确实得到了路径,但我的代码在路径中添加了C:"而不是\PCNAME\datafolder\data.mdb"我已经阅读了很多关于此的内容,但没有任何意义,因为我的代码看起来完全符合它应有的要求,除非我遇到了这种复杂情况.

Dll Netapi32 however while i do get the path exactly as it should be my code adds "C:" to the path instead of "\PCNAME\datafolder\data.mdb" I have read a lot on this and none of it makes much sense because my code looks exactly as it should except i get that complication.

推荐答案

您的代码行看起来不错.尝试在字符串前添加 @ 或像这样添加反斜杠 \\\\" + PCName

Your code line is looking pretty good. Try to add @ before the string or add back slash like this \\\\" + PCName

string myconnectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\\\" + PCName + "\\datafolder\\data.mdb";

如果仍然产生问题,则将该数据库共享文件夹指定为映射驱动器并使用类似的内容.例如映射驱动器是 Z: (\\PCName\ApplicationFolder)

If still it creates problem then assign that database shared folder as a Mapped Drive and use something like this. for example mapped drive is Z: (\\PCName\ApplicationFolder)

string myconnectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Z:\datafolder\data.mdb";

这个解决方案也不起作用,那么问题可能出在网络电脑权限上.

also this solution does not working then the problem may be in network pc permission.

这篇关于连接到 LAN 网络位置上的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆