vb的recordset的open方法执行多条sql语句,单条可以执行了,多条如何执行,用nextrecordset总是出错。请大家帮忙想想办法,或改改程序。谢谢,单条执行程序如下:
Private Sub Command1_Click()
Dim cn As New adodb.Connection
Dim cmd As New adodb.Command
Dim rs As New adodb.Recordset
Dim rs2 As adodb.Recordset '后添加的
Dim a11 As Date
Dim a12 As Integer
a11 = #7/20/2010#
a12 = 13001
Dim j As Integer
Dim path1 As String
Dim path2 As String
Dim sql As String
Dim sql1 As String
path1 = "c:\7月20日"
path2 = "c:\7月21日"
cn.Open "Provider=OraOLEDB.Oracle.1;User ID=12;password=df;Data Source=192.168.1.32:1521/pdbqz;Persist Security Info=False"
rs.ActiveConnection = cn
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
sql = "select * from QZDATA.QZ_312_DYS_02 where STARTDATE=to_date('" & a11 & "','YYYY-MM-DD') and ITEMID=3123 and STATIONID=" & a12 & "and pointid=1"
rs.Source = sql
rs.Open
Call blobtofile(rs.Fields("OBSVALUE"), path1) '读3123测项的数据
Set rs = Nothing
End
End Sub
Private Sub Command1_Click()
Dim cn As New adodb.Connection
Dim cmd As New adodb.Command
Dim rs As New adodb.Recordset
Dim rs2 As adodb.Recordset '后添加的
Dim a11 As Date
Dim a12 As Integer
a11 = #7/20/2010#
a12 = 13001
Dim j As Integer
Dim path1 As String
Dim path2 As String
Dim sql As String
Dim sql1 As String
path1 = "c:\7月20日"
path2 = "c:\7月21日"
cn.Open "Provider=OraOLEDB.Oracle.1;User ID=12;password=df;Data Source=192.168.1.32:1521/pdbqz;Persist Security Info=False"
rs.ActiveConnection = cn
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
sql = "select * from QZDATA.QZ_312_DYS_02 where STARTDATE=to_date('" & a11 & "','YYYY-MM-DD') and ITEMID=3123 and STATIONID=" & a12 & "and pointid=1"
rs.Source = sql
rs.Open
Call blobtofile(rs.Fields("OBSVALUE"), path1) '读3123测项的数据
Set rs = Nothing
End
End Sub
Dim cn As New adodb.Connection
Dim cmd As New adodb.Command
Dim rs As New adodb.Recordset
Dim rs2 As adodb.Recordset '后添加的
Dim a11 As Date
Dim a12 As Integer
a11 = #7/20/2010#
a12 = 13001
Dim j As Integer
Dim path1 As String
Dim path2 As String
Dim sql As String
Dim sql1 As String
path1 = "c:\7月20日"
path2 = "c:\7月21日"
cn.Open "Provider=OraOLEDB.Oracle.1;User ID=12;password=df;Data Source=192.168.1.32:1521/pdbqz;Persist Security Info=False"
rs.ActiveConnection = cn
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
sql = "select * from QZDATA.QZ_312_DYS_02 where STARTDATE=to_date('" & a11 & "','YYYY-MM-DD') and ITEMID=3123 and STATIONID=" & a12 & "and pointid=1"
rs.Source = sql
rs.Open
while not rs.eof
Call blobtofile(rs.Fields("OBSVALUE"), path1) '读3123测项的数据
rs.movenext
wend
rs.close
Set rs = Nothing
End
End Sub
Dim cn As New adodb.Connection
Dim cmd As New adodb.Command
Dim rs As New adodb.Recordset
Dim rs2 As adodb.Recordset '后添加的
Dim a11 As Date
Dim a12 As Integer
a11 = #7/20/2010#
a12 = 13001
Dim j As Integer
Dim path1 As String
Dim path2 As String
Dim sql As String
Dim sql1 As String
path1 = "c:\7月20日"
path2 = "c:\7月21日"
cn.Open "Provider=OraOLEDB.Oracle.1;User ID=12;password=df;Data Source=192.168.1.32:1521/pdbqz;Persist Security Info=False"
rs.ActiveConnection = cn
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
sql = "select * from QZDATA.QZ_312_DYS_02 where STARTDATE=to_date('" & a11 & "','YYYY-MM-DD') and ITEMID=3123 and STATIONID=" & a12 & "and pointid=1"
rs.Source = sql
rs.Open
While Not rs.EOF
Call blobtofile(rs.Fields("OBSVALUE"), path1) '读3123测项的数据
rs.movenext
Wend
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
' End
End Sub
Private Sub Command1_Click()
Dim cn As New adodb.Connection
Dim cmd As New adodb.Command
Dim rs As New adodb.Recordset
Dim rs2 As adodb.Recordset '后添加的
Dim a11 As Date
Dim a12 As Integer
a11 = #7/20/2010#
a12 = 13001
Dim j As Integer
Dim path1 As String
Dim path2 As String
Dim sql As String
Dim sql1 As String
path1 = "c:\7月20日"
path2 = "c:\7月21日"
cn.Open "Provider=OraOLEDB.Oracle.1;User ID=12;password=df;Data Source=192.168.1.32:1521/pdbqz;Persist Security Info=False"
rs.ActiveConnection = cn
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
sql = "select * from QZDATA.QZ_312_DYS_02 where STARTDATE=to_date('" & a11 & "','YYYY-MM-DD') and ITEMID=3123 and STATIONID=" & a12 & "and pointid=1"
sql2= "select * from QZDATA.QZ_312_DYS_02 where STARTDATE=to_date('" & b11 & "','YYYY-MM-DD') and ITEMID=3124 and STATIONID=" & a12 & "and pointid=1"
rs.Source = sql
rs.Open
While Not rs.EOF
Call blobtofile(rs.Fields("OBSVALUE"), path1) '读3123测项的数据
rs.movenext
Wend
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
' End
End Sub
Dim cn As New adodb.Connection
Dim cmd As New adodb.Command
Dim rs As New adodb.Recordset
Dim rs2 As adodb.Recordset '后添加的
Dim a11 As Date
Dim a12 As Integer
a11 = #7/20/2010#
a12 = 13001
Dim j As Integer
Dim path1 As String
Dim path2 As String
Dim sql As String
Dim sql1 As String
path1 = "c:\7月20日"
path2 = "c:\7月21日"
cn.Open "Provider=OraOLEDB.Oracle.1;User ID=12;password=df;Data Source=192.168.1.32:1521/pdbqz;Persist Security Info=False"
rs.ActiveConnection = cn
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
'第一个
sql = "select * from QZDATA.QZ_312_DYS_02 where STARTDATE=to_date('" & a11 & "','YYYY-MM-DD') and ITEMID=3123 and STATIONID=" & a12 & "and pointid=1"
rs.Source = sql
rs.Open
While Not rs.EOF
Call blobtofile(rs.Fields("OBSVALUE"), path1) '读3123测项的数据
rs.movenext
Wend
rs.Close
'第二个
sql = "select * from QZDATA.QZ_312_DYS_02 where STARTDATE=to_date('" & a11 & "','YYYY-MM-DD') and ITEMID=3123 and STATIONID=" & a12 & "and pointid=1"
rs.Source = sql
rs.Open
While Not rs.EOF
Call blobtofile(rs.Fields("OBSVALUE"), path1) '读3123测项的数据
rs.movenext
Wend
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
' End
End Sub