If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > How to get recordset in ASP from MSSQL stored procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-06, 17:51
Nataly Nataly is offline
Registered User
 
Join Date: Nov 2004
Posts: 9
Red face How to get recordset in ASP from MSSQL stored procedure

I have stored procedure with couple input parameters (MS SQL) which creates temporary table and returns recordset as the result from that tamporary table. Stored procedure works ok on its own.
I need to get that recordset in ASP but it doesn't work !?!

Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = Conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "PROC_DrawingTest"

cmd.Parameters.Append(cmd.CreateParameter("jobno", adVarChar, adParamInput, 20, Session("JobNumber")))
cmd.Parameters.Append(cmd.CreateParameter("strdwgs ", adVarChar, adParamInput, 1000, sqlstr))

Set rec = cmd.Execute()

If not rec.EOF then
- here I have an error

Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.

Please, help!
Reply With Quote
  #2 (permalink)  
Old 10-12-06, 18:21
jezemine jezemine is offline
another indirection layer
 
Join Date: May 2004
Location: Seattle
Posts: 1,312
how about a call to rec.Open() before you read from it?
__________________
elsasoft.org
Reply With Quote
  #3 (permalink)  
Old 10-13-06, 08:30
wash wash is offline
Registered User
 
Join Date: Aug 2004
Location: Pune,India
Posts: 94
I suppose if the recordset is returned as the return value , there is no need to call the "Open" method.

Instead try this :


Set rec = cmd.Execute()
if not rec nothing then
If not rec.EOF then
- here I have an error
end if
Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
__________________
In GOD we believe. Everything else we Test!
Reply With Quote
  #4 (permalink)  
Old 10-13-06, 14:19
Nataly Nataly is offline
Registered User
 
Join Date: Nov 2004
Posts: 9
Thank you, guys!
The problem is solved now. I've added SET NOCOUNT ON and SET NOCOUNT OFF within stored procedure for INSERT and SELECT and it works just fine.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On