本帖最后由 cashiba 于 2019-8-16 00:10 编辑 Public Sub Main()
On Error GoTo ErrorHandler
Dim Cnxn2 As ADODB.Connection
Dim rstSchema As ADODB.Recordset
Dim strCnxn As String
Set Cnxn2 = New ADODB.Connection
strCnxn = "Provider=sqloledb;" & _
"Data Source=MySqlServer;Initial Catalog=Pubs;Integrated Security=SSPI; "
Cnxn2.Open strCnxn
Set rstSchema = Cnxn2.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "VIEW"))
Do Until rstSchema.EOF
Debug.Print "Table name: " & _
rstSchema!TABLE_NAME & vbCr & _
"Table type: " & rstSchema!TABLE_TYPE & vbCr
rstSchema.MoveNext
Loop
rstSchema.Close
Cnxn2.Close
Set rstSchema = Nothing
Set Cnxn2 = Nothing
Exit Sub
ErrorHandler:
If Not rstSchema Is Nothing Then
If rstSchema.State = adStateOpen Then rstSchema.Close
End If
Set rstSchema = Nothing
If Not Cnxn2 Is Nothing Then
If Cnxn2.State = adStateOpen Then Cnxn2.Close
End If
Set Cnxn2 = Nothing
If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
.Local $oCn = ObjCreate("adodb.connection")
Local $oRs = ObjCreate("adodb.recordset")
Local $sdb = @ScriptDir & "\Data.accdb"
Local $sPw = ""
Local $sCn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & $sdb & _
";persist Security Info=False;Jet OLEDB:Database Password=" & $sPw
$oCn.Open($sCn)
Local $t = ["", "", "", "VIEW"]
Local $oSm = $oCn.OpenSchema(20, $t)
Local $t = ["", "", "", "VIEW"]
Local $oSm = $oCn.OpenSchema(20, $t)
Local $oSm = $oCn.OpenSchema(20, $t)
Local $oSm = $oCn^ ERROR
Array(Empty, Empty, Empty, "VIEW")
$t = ["", "", "", "VIEW"]
$t = [Null, Null, Null, "VIEW"]
以上错误不知道是不是empty改成""或Null造成的......
AU3里空值好像也就""或Null以及0三种形式
不知道为啥运行有错误,还是问题不在这里呢.....
|