您好我没有VB6或VB.NET的经验,但我正在尝试将一些旧代码转换为.NET。 VB6使用PrivDBEngine。
Public oDbEngine As New PrivDBEngine
经过一些谷歌搜索,这看起来像DAO。有人告诉我用ADO.NET替换它的用法。我粘贴在下面的代码中我看到的每个位置作为参考,以防它有帮助。我将谷歌搜索“PrivateDBEngine DAO到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
End Sub