嗨,我没有使用VB6或VB.NET的经验,但正在尝试将一些旧代码转换为.NET。VB6使用PrivDBEngine。
Public oDbEngine As New PrivDBEngine在谷歌上搜索后,这个看起来像刀。我被告知要用ADO.NET替换它的用法,我在下面的代码中看到的每一个地方都粘贴了它,作为参考,以防有帮助。我将在googling上搜索"PrivateDBEngine DAO to ADO.NET“,但是如果有人知道ADO.NET中有类似的东西,或者甚至有一些有用的链接,请告诉我。我应该调查一下DataSet吗?非常感谢您的时间和耐心。我遇到的其他地方有:
' Build the proper connection string. If ODBC, the
' options line of the OpenDatabase method accepts the
' connection string. If Access, just pass in the
' filename
sPassword = Password
Select Case ConnType
Case DBTYPE_ACCESS
DBFilename = ConnectString
If (Len(UserName) = 0 And Len(Password) <> 0) Then
DBOptions = ";PWD=" + Password
sPassword = ""
Else
DBOptions = ""
End If
If (UserName = "") Then
UserName = "Admin"
Else
UserName = UserName
End If
If (Len(SystemMDB) <> 0) Then
---> oDbEngine.SystemDB = SystemMDB <-----------
End If还包括:
' Handle UserName and Password.
Set oWorkSpace = oDbEngine.CreateWorkspace("Test", UserName, sPassword)最后:
Sub CleanUpDBConnection()
On Error Resume Next
' Close the recordsets
grsIndexTable.Close
grsDocTable.Close
' Close the database
If Connected Then
DBConnection.Close
Set DBConnection = Nothing
oWorkSpace.Close
Set oWorkSpace = Nothing
Set oDbEngine = Nothing
CurrentDTable = ""
CurrentITable = ""
Connected = False
End If结束子对象
发布于 2022-01-13 15:59:06
PrivDBEngine是DAO的一部分。它类似于DBEngine。
在应用程序中,可能需要连接到具有不同工作组安全连接的多个数据库。PrivDBEngine允许您独立于DBEngine执行此操作。
一个常见的场景是主数据库(通过DBEngine连接),它有指向其他数据库的数据,每个数据库都有自己的工作组安全设置。在这种情况下,将使用PrivDBEngine来打开这些数据库。
我不记得一次是否可以支持3个工作组安全设置,但您肯定可以根据需要重置PrivDBEngine变量,而不会影响已经使用DBEngine变量打开的所有记录集。
如果使用Access数据库,则应该在VB.NET中使用相同的ACE/DAO/DBEngine代码。ADO可以替换一些ACE/DAO代码,特别是当您使用SQL Server而只是检索数据时,但是如果您使用Access数据库,ACE/DAO支持ADO不支持的特性。
https://stackoverflow.com/questions/25453004
复制相似问题