大家好
我用VBA连线Oracle查询要回传笔数
.RecordCount 总是回传-1
.Fields.Count 可以正常回传字段数量
可以帮忙看一下是哪边错了吗
再拜托大家了
谢谢!
Sub test()
Dim strConOracle As String
strConOracle = "Provider=MSDASQL.1;Persist Security Info=False;User ID=" &
sql_username & ";Password=" & sql_password & ";Data Source=abcdtest"
Set oConOracle = CreateObject("ADODB.Connection")
Set oRsOracle = CreateObject("ADODB.RecordSet")
Set OracleCommand = CreateObject("ADODB.Command")
oConOracle.Open strConOracle
With OracleCommand
.ActiveConnection = oConOracle
.CommandType = 1
.CommandText = "SELECT * FROM DBACD.TEST001"
.CommandTimeout = 300
End With
Set oRsOracle = OracleCommand.Execute
MsgBox "column count: " & oRsOracle.Fields.Count & vbLf & "row_count: " &
oRsOracle.RecordCount
Set oConOracle = Nothing: Set oRsOracle = Nothing: Set OracleCommand = Not
hing
End Sub