问题是您尝试使用 COM 对象,而实际上您应该使用本机System.Data.OleDb类。
根据 Microsoft 提供的示例,这里是使用本机类重写的代码:
Dim connectionString As String
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("games.mdb")
Using connection As New System.Data.OleDb.OleDbConnection(connectionString)
Using command As New System.Data.OleDb.OleDbCommand("select * FROM [index] where ID1=1")
' Set the Connection to the new OleDbConnection.
command.Connection = connection
' Open the connection and execute the select command.
Try
connection.Open()
Dim oReader As System.Data.OleDb.OleDbDataReader
oReader = command.ExecuteReader()
If oReader.Read() Then
Image1.ImageUrl = "images/" + oReader("url").ToString
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Using
' The connection is automatically closed when the code exits the Using block.
End Using