Forum Discussion
culisse
14 years agoContributor
Okay - our development team got me on the right track and I can now obtain Stored Procedure results. SmartBear only gave the example with "CreateADOStoredProc" which will only get you a return value. In order to obtain the results of the StoredProcedure, use "CreateADODataset". Below is an example...
Sub CallStoredProc()
' Create the new IAQAADODataset object
Set DSet = ADO.CreateADODataset
' Specify the connection string
DSet.ConnectionString = "..." 'Insert your connection string here
' Specify the command type and text
DSet.CommandType = cmdStoredProc
DSet.CommandText = "..." 'Insert Stored Proc name here
' Adding an input parameter if required
Call DSet.Parameters.AddParameter()
DSet.Parameters.Items(0).name = "..."
DSet.Parameters.Items(0).DataType = "..."
DSet.Parameters.Items(0).Direction = adParamInput
DSet.Parameters.Items(0).Value = "..."
' Open the dataset
DSet.Open()
DSet.First() 'Just sample here of a value from the first record of the result set of the Stored Proc
varCount = DSet.FieldByName("VisitCount").Value
Call Log.Message("Count: " & varCount)
DSet.Close()
End Sub
Sub CallStoredProc()
' Create the new IAQAADODataset object
Set DSet = ADO.CreateADODataset
' Specify the connection string
DSet.ConnectionString = "..." 'Insert your connection string here
' Specify the command type and text
DSet.CommandType = cmdStoredProc
DSet.CommandText = "..." 'Insert Stored Proc name here
' Adding an input parameter if required
Call DSet.Parameters.AddParameter()
DSet.Parameters.Items(0).name = "..."
DSet.Parameters.Items(0).DataType = "..."
DSet.Parameters.Items(0).Direction = adParamInput
DSet.Parameters.Items(0).Value = "..."
' Open the dataset
DSet.Open()
DSet.First() 'Just sample here of a value from the first record of the result set of the Stored Proc
varCount = DSet.FieldByName("VisitCount").Value
Call Log.Message("Count: " & varCount)
DSet.Close()
End Sub