Looking for examples of calling sp's in ado...

Results 1 to 2 of 2

Thread: Looking for examples of calling sp's in ado...

  1. #1
    Join Date
    Dec 1969

    Default Looking for examples of calling sp's in ado...

    Hi I am looking for some example code of how to call a stored procedure in SQL using the ado command object.<BR><BR>If my sp was..<BR>sp_checkUsername varUser,varPass <BR><BR>How would I call this from ado.<BR><BR>Another question I have would be how would you parse the info fields from a SP to an asp page ?<BR><BR>i.e ..<BR><BR>Lets say my sp is <BR><BR>Create Proc sp_selectAllproducts<BR> select * from products<BR><BR>----------------------------<BR>and I ran this from ado then how would i parse those fields to the asp variables.<BR><BR>Thanks <BR><BR>Dwane Lumley<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Looking for examples of calling sp's in ad

    This is done using the command and parameter objects:<BR><BR>set cmd = server.createobject("ADODB.command")<BR>set p1 = server.createobject("ADODB.Parameter")<BR>set p2 = server.createobject("ADODB.Parameter")<BR>set cn = server.createobject("ADODB.Connection")<BR>set rsProducts = server.createobject("ADODB.Recordset")<BR>cn.open {Connection string}<BR><BR>cmd.ActiveConnection = cn<BR>cmd.CommandType = 4 (Constant for stored procedure)<BR>cmd.CommandText = "sp_SelectAllProducts"<BR><BR>set p1 = cmd.createparameter("varUser", {parameter properties})<BR>cmd.parameters.Append p1<BR><BR>set p2 = cmd.createparameter("varPass", {parameter properties})<BR>cmd.parameters.Append p2<BR><BR>set rsProducts = cmd.Execute<BR><BR>Then loop through rsProducts to put all the values onto the ASP page.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts