Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: How do i return a set of records from a stored procedure?


Message #1 by <arun@t...> on Tue, 29 Aug 2000 21:35:16 +0530
Hi,



I am a beginner to asp and hence dont know whether this is a tough/easy

question.



I have learnt from a few sources that by default stored procedures are

better to use than firing direct sql statements.

How do i return a set of records from a stored procedure. As of now i am

using a direct sql statement and retrieving them using rs.fields and

rs.movenext. But is this the best way or should i use, stored procedures for

that also.



Any references/guidelines would help



Thanks

Arun



Message #2 by ckoski@w... on Tue, 29 Aug 2000 12:39:15 -0400
very easy....





here's an example...



  DSN = "DSN=ExampleDatabase;"

  set dbConnection = Server.CreateObject("ADODB.Connection")

  dbConnection.CursorLocation = adUseServer

  dbConnection.Open DSN

  set rs = dbConnection.Execute("sp_function @intparameter="&int_param&",

@charparameter='"&char_param&"'")





That's how easy it is... of course, there are other ways to do this... more

complex using the Command object...



  Dim cmd, rs

  set cmd = Server.CreateObject("ADODB.Command")

  if content_id = null or content_id = "" then

   Err.Clear

   Err.Raise vbObjectError + 2510,"Content ID is invalid"

  end if

  cmd.ActiveConnection = dbConnection

  cmd.CommandType = adCmdStoredProc

  cmd.CommandText = "sp_function"



  cmd.Parameters.Append cmd.CreateParameter ("intparameter", adInteger,

adParamInput,,int_param)

  cmd.Parameters.Append cmd.CreateParameter

("charparameter",adVarChar,adParamInput,50,char_param)

  ' ***  here's where you create the recordset

  set rs = cmd.Execute

  ' *** then do whatever you need with the recordset....  lalala...

  set cmd = nothing



I hope these examples help!



Good luck!



Cory Koski

Web Programmer

Wabang Creative Technology and TBSource.com

Brainbench e-certified Master ASP programmer

(xxx) xxx-xxxx  ext. 41



----- Original Message -----

To: "ASP Databases" <asp_databases@p...>

Sent: Tuesday, August 29, 2000 12:05 PM

Subject: [asp_databases] How do i return a set of records from a stored

procedure?





> Hi,

>

> I am a beginner to asp and hence dont know whether this is a tough/easy

> question.

>

> I have learnt from a few sources that by default stored procedures are

> better to use than firing direct sql statements.

> How do i return a set of records from a stored procedure. As of now i am

> using a direct sql statement and retrieving them using rs.fields and

> rs.movenext. But is this the best way or should i use, stored procedures

for

> that also.

>

> Any references/guidelines would help

>

> Thanks

> Arun

>

>


  Return to Index