急:vb连接oracle已成功,现在查询出错,请帮忙。
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rst As New ADODB.Recordset
Dim i As Integer
cn.Open " Provider=MSDAORA.1;User ID=ta;password=123;Data Source=129.13.128.71:1521/pdbqz;Persist Security Info=False"
Set cmd.ActiveConnection = cn
cmd.CommandText = "select * from QZDATA.QZ_351_DYS_02 where STARTDATE=13139"
rst.CursorLocation = adUseClient
'rst.Open strQuery, cn, adOpenStatic, adLockOptimistic
rst.Open cmd, cn, adOpenStatic, adLockOptimistic
rst.Sort = "STARTDATE"
rst.MoveFirst
Do
For j = 1 To rst.RecordCount - 1
Debug.Print rst.Fields("STARTDATE") & " " & rst.Fields("DATE_INDEX")
rst.MoveNext
If rst.EOF Or rst.BOF Then
GoTo 100
End If
Next j
Loop
100: Set rst = Nothing
Set cmd = Nothing
Set cn = Nothing
End Sub
提示错误:实时错误‘3707‘ 无法更改以命令对象为源的记录集对象的ActiveConnection属性。
------解决方案--------------------
ORA-3707?这个?
应该不是吧,是你程序的错误吧
------解决方案--------------------
Set cmd.ActiveConnection = cn
我觉得是这句有问题,没有用过VB连接ORACLE