T
Terry
I need to get a recordset from a stored procedure, however I think my coding
is wrong and get an empty recordset as an error 3021 is returned from the
recordcount line.
Regards
Set cnn = New ADODB.Connection
strdb = "Q:\ManagementInformation.adp"
' Open connection
With cnn
.ConnectionString = CurrentProject.BaseConnectionString
.CursorLocation = adUseClient
.Open
End With
Dim dteStartDate As Date
Dim dteEndDate As Date
dteStartDate = Forms!frmReports!txtStartDate
dteEndDate = Forms!frmReports!txtEndDate
Set cmd = New ADODB.Command
Set param1 = New ADODB.Parameter
Set param2 = New ADODB.Parameter
With param1
.Name = "@StartDate"
.Type = adDate
.Size = 2
.Value = dteStartDate
End With
With param2
.Name = "@EndDate"
.Type = adDate
.Size = 2
.Value = dteEndDate
End With
With cmd
.Parameters.Append param1
.Parameters.Append param2
.ActiveConnection = cnn
.CommandType = adCmdStoredProc
.CommandText = "floydsp_POPOrderChaser"
End With
' Open recordset
Set rst = New ADODB.Recordset
Set rst = cmd.Execute
intCount = rst.RecordCount
is wrong and get an empty recordset as an error 3021 is returned from the
recordcount line.
Regards
Set cnn = New ADODB.Connection
strdb = "Q:\ManagementInformation.adp"
' Open connection
With cnn
.ConnectionString = CurrentProject.BaseConnectionString
.CursorLocation = adUseClient
.Open
End With
Dim dteStartDate As Date
Dim dteEndDate As Date
dteStartDate = Forms!frmReports!txtStartDate
dteEndDate = Forms!frmReports!txtEndDate
Set cmd = New ADODB.Command
Set param1 = New ADODB.Parameter
Set param2 = New ADODB.Parameter
With param1
.Name = "@StartDate"
.Type = adDate
.Size = 2
.Value = dteStartDate
End With
With param2
.Name = "@EndDate"
.Type = adDate
.Size = 2
.Value = dteEndDate
End With
With cmd
.Parameters.Append param1
.Parameters.Append param2
.ActiveConnection = cnn
.CommandType = adCmdStoredProc
.CommandText = "floydsp_POPOrderChaser"
End With
' Open recordset
Set rst = New ADODB.Recordset
Set rst = cmd.Execute
intCount = rst.RecordCount