Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordsets from Stored Procedures

Status
Not open for further replies.

mhall

Technical User
Sep 26, 2000
13
GB
Hi

I am using the following code to run my stored procedure and the creating a recordset to hold the results so that I can move through and display the results. My problem is that the recordcount function and previous functions of the recordset do not work could anybody tell me why.

GetConnectionString

With cn
' Establish DSN-less connection
.ConnectionString = ConnectionString
.ConnectionTimeout = 10
.Open
End With

Dim objComm As ADODB.Command
Dim pr_Parameters(2) As Variant
Set objComm = New ADODB.Command

With objComm
.ActiveConnection = cn
.CommandText = "sp_get_comments"
.CommandType = adCmdStoredProc
End With

pr_Parameters(0) = frmParts.txtOrderNo.Text
pr_Parameters(1) = frmParts.flxParts.TextMatrix(frmParts.flxParts.RowSel, 0)
pr_Parameters(2) = frmParts.flxParts.TextMatrix(frmParts.flxParts.RowSel, 3)

Set rsdisplayComments = objComm.Execute("sp_get_comments", pr_Parameters, adCmdStoredProc)

any help would be greatly appriciated

thanks

Matt

 
It is normal. When you use Execute method of Command or Connection object, it returns a forward-only recordset and it does not allowed you to move back (that is using .MovePrevious method). RecordCount will return -1 in this case. So, you can use Recordset.Open instead of Command.Execute. Just remember to set CursorType propertu of Recordset object to something other than 'Forward Only' before opening it. Mohammad Mehran Nikoo, MCSD mohmehran@msn.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top