我在VB6中用如下代码连接数据库,但在VB.net中就不行 Public Function TransactSQL(ByVal sql As String) As ADODB.Recordset Dim con As ADODB.Connection Dim rs As ADODB.Recordset Dim strConnection As String Dim strArray() As String Set con = New ADODB.Connection '创建连接 Set rs = New ADODB.Recordset '创建记录集 On Error GoTo TransactSQL_Error strConnection = "Provider=Microsoft.jet.oledb.4.0;Data Source=" & App.Path & "\3d.mdb" strArray = Split(sql) con.Open strConnection '打开连接 If StrComp(UCase$(strArray(0)), "select", vbTextCompare) = 0 Then rs.Open Trim$(sql), con, adOpenKeyset, adLockOptimistic Set TransactSQL = rs '返回记录集 iflag = 1 Else con.Execute sql '执行命令 iflag = 1 End If TransactSQL_Exit: Set rs = Nothing Set con = Nothing Exit Function TransactSQL_Error: MsgBox "查询错误:" & Err.Description iflag = 2 Resume TransactSQL_Exit
End Function 请教在VB.net中如何连接*.mbd数据库