ADO Program
Dim Con As New ADODB.Connection
Dim Rst1 As New ADODB.Recordset
Dim Rst2 As New ADODB.Recordset
Dim Rst3 As New ADODB.Recordset
Dim Cmd As New ADODB.Command
Dim Prm1 As New ADODB.Parameter Dim Prm2 As New ADODB.Parameter Con.Provider = "OraOLEDB.Oracle"
Con.ConnectionString = "Data Source=MyOraDb;" & _
"User ID=scott;Password=tiger;"
Con.Open
Cmd.ActiveConnection = Con' Although Employees.GetEmpRecords() takes four parameters, only
' two need to be bound because Ref cursor parameters are automatically
' bound by the provider. Set Prm1 = Cmd.CreateParameter("Prm1", adSmallInt, adParamInput, , 30)
Cmd.Parameters.Append Prm1
Set Prm2 = Cmd.CreateParameter("Prm2", adSmallInt, adParamOutput)
Cmd.Parameters.Append Prm2 ' Enable PLSQLRSet property
Cmd.Properties ("PLSQLRSet") = TRUE ' Stored Procedures returning resultsets must be called using the
' ODBC escape sequence for calling stored procedures.
Cmd.CommandText = "{CALL Employees.GetEmpRecords(?, ?)}" ' Get the first recordset
Set Rst1 = Cmd.Execute ' Disable PLSQLRSet property
Cmd.Properties("PLSQLRSet") = FALSE ' Get the second recordset
Set Rst2 = Rst1.NextRecordset' Just as in a stored procedure, the REF CURSOR return value must
' not be bound in a stored function.
Prm1.Value = 7839
Prm2.Value = 0' Enable PLSQLRSet property
Cmd.Properties("PLSQLRSet") = TRUE ' Stored Functions returning resultsets must be called using the
' ODBC escape sequence for calling stored functions.
Cmd.CommandText = "{CALL Employees.GetDept(?, ?)}" ' Get the rowset
Set Rst3 = Cmd.Execute ' Disable PLSQLRSet
Cmd.Properties ("PLSQLRSet") = FALSE' Clean up
Rst1.Close
Rst2.Close
Rst3.Close看下有没有帮助
Dim Con As New ADODB.Connection
Dim Rst1 As New ADODB.Recordset
Dim Rst2 As New ADODB.Recordset
Dim Rst3 As New ADODB.Recordset
Dim Cmd As New ADODB.Command
Dim Prm1 As New ADODB.Parameter Dim Prm2 As New ADODB.Parameter Con.Provider = "OraOLEDB.Oracle"
Con.ConnectionString = "Data Source=MyOraDb;" & _
"User ID=scott;Password=tiger;"
Con.Open
Cmd.ActiveConnection = Con' Although Employees.GetEmpRecords() takes four parameters, only
' two need to be bound because Ref cursor parameters are automatically
' bound by the provider. Set Prm1 = Cmd.CreateParameter("Prm1", adSmallInt, adParamInput, , 30)
Cmd.Parameters.Append Prm1
Set Prm2 = Cmd.CreateParameter("Prm2", adSmallInt, adParamOutput)
Cmd.Parameters.Append Prm2 ' Enable PLSQLRSet property
Cmd.Properties ("PLSQLRSet") = TRUE ' Stored Procedures returning resultsets must be called using the
' ODBC escape sequence for calling stored procedures.
Cmd.CommandText = "{CALL Employees.GetEmpRecords(?, ?)}" ' Get the first recordset
Set Rst1 = Cmd.Execute ' Disable PLSQLRSet property
Cmd.Properties("PLSQLRSet") = FALSE ' Get the second recordset
Set Rst2 = Rst1.NextRecordset' Just as in a stored procedure, the REF CURSOR return value must
' not be bound in a stored function.
Prm1.Value = 7839
Prm2.Value = 0' Enable PLSQLRSet property
Cmd.Properties("PLSQLRSet") = TRUE ' Stored Functions returning resultsets must be called using the
' ODBC escape sequence for calling stored functions.
Cmd.CommandText = "{CALL Employees.GetDept(?, ?)}" ' Get the rowset
Set Rst3 = Cmd.Execute ' Disable PLSQLRSet
Cmd.Properties ("PLSQLRSet") = FALSE' Clean up
Rst1.Close
Rst2.Close
Rst3.Close看下有没有帮助
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货