Database 用VB.net查询远程Access数据库的更好解决方案
请告诉我查询远程访问数据库有更好的解决方案 我们目前正在使用它,因为到目前为止,我们无法连接sp_链接服务器。我觉得这是一个可怕的黑客行为,我想一劳永逸地完成整个网络地图业务Database 用VB.net查询远程Access数据库的更好解决方案,database,vb.net,networking,linked-server,Database,Vb.net,Networking,Linked Server,请告诉我查询远程访问数据库有更好的解决方案 我们目前正在使用它,因为到目前为止,我们无法连接sp_链接服务器。我觉得这是一个可怕的黑客行为,我想一劳永逸地完成整个网络地图业务 'This is for access 2007 'DataBase on Local Machine '*************************************************************************************************
'This is for access 2007
'DataBase on Local Machine
'*************************************************************************************************
'Before a conneciton is made this code sends the credentials to the remote path.
Dim objNetwork As Object
objNetwork = Microsoft.VisualBasic.CreateObject("WScript.Network")
'this line below deletes the drive if there is one so that a correct mapped drive can be created
'objNetwork.RemoveNetworkDrive("W:")
Dim DriveLetter = "W:" ' *** This drive needs to be deleted after it is created see the end of this sub for deletion
Dim RemotePath = "\\volume10\pickles\toads\rocks\sheepy\almostTodb\behindTheScenes"
Dim UserID = "sysama01\starUser"
Dim UserPWD = "secretPass"
objNetwork.MapNetworkDrive(DriveLetter, RemotePath, False, UserID, UserPWD)
'Syntax()
'****.MapNetworkDrive(strLocalDrive, strRemoteShare, [persistent], [strUser], [strPassword])
'Options:
'strLocalDrive : The drive letter (e.g. L:)
'strRemoteShare : The UNC path to the remote drive \\MyServer\MyPrinter
'(String value)
'persistent : True/False - store the mapping persistently in the users profile
'default = false
'strUser : The user name. (Optional)
'strPassword : The password. (Optional)
' Location for code http://ss64.com/vb/drivemap.html
'*************************************************************************************************
'DataBase on Network Drive
objConn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=W:\SuperDeliciousFoodDB.accdb;Jet OLEDB:Database Password=databasePasswordHere")
'DataBase on Network Drive
objConn.Open()
objCmd = New OleDbCommand("SELECT * from pancakeTable, objConn)
objReader = objCmd.ExecuteReader
...
'Do more codestuffs here
objNetwork.RemoveNetworkDrive("W:")
我建议。如果使用“链接表”选项,您可以继续使用现有Access数据库中的表单、报表和查询,同时仍然可以从尽可能多的连接远程查询数据。您是否可以使用与Access数据库托管在同一服务器上的web服务?I。。。你不这么认为吗?老实说,我不这么认为,因为access数据库位于我的计算机的P驱动器上(我相信对于我们的整个内部网…)。我认为主要的问题是有进入这个特定目录的凭证,我似乎无法将其与OleDbCommand或其他任何东西一起传递。这是大厅那边那个家伙的数据库。。。连接到itI有这么多困难,这让人非常沮丧。我不认为您可以切换到SQL Server express吗?如果access db仍然需要用于遗留内容,则可以将SQL server表添加为链接表。它使用封装在一个小类中的WindowsNETAPI。希望能有帮助。@SteveDog:我不知道我是否理解“链接表”的概念。基本上是一个linkedserver,但规模较小?此外,access db不仅仅是用于遗留的东西(我希望是这样)。楼下那个家伙用它来跟踪一些有用的信息(我希望他能把这些信息放进我们的数据库!)---史蒂夫:我。。。我觉得我太笨了,没法掌握那些东西,我道歉!