Stored SQL Procedures and the Recordset Query

Results 1 to 2 of 2

Thread: Stored SQL Procedures and the Recordset Query

  1. #1
    Johnny Boy Guest

    Default Stored SQL Procedures and the Recordset Query

    I&#039ve got the follwoing code<BR><BR>&#060;%<BR>Option Explicit <BR>%&#062;<BR>&#060;!--#include virtual="" --&#062;<BR>&#060;%<BR>Dim dcnDB<BR>Dim cmdQuery<BR>Dim rsQuery<BR>Dim parID<BR><BR>Set dcnDB = Server.CreateObject("ADODB.Connection")<BR> dcnDB.Open "hlgs", "sa"<BR><BR>Set cmdQuery = Server.CreateObject("ADODB.Command")<BR>cmdQuery.C ommandText = "Web_Get_Job_Header"<BR>Set cmdQuery.ActiveConnection = dcnDB<BR><BR>Set parID = cmdQuery.CreateParameter("number", adInteger, adParamInput)<BR>cmdQuery.Parameters.Append parID<BR><BR>cmdQuery.Parameters("number") = 315<BR><BR>Set rsQuery = Server.CreateObject("ADODB.Recordset")<BR>rsQuery. Open cmdQuery<BR><BR>Response.Write cmdQuery.Parameters("number")<BR><BR>&#039Response .Write rsQuery("Traffic.Customer_Ref")<BR><BR>%&#062;<BR> works fine the number 315 comes up at the end...<BR><BR>Not very useful but hey it works...<BR><BR>I uncomment the last line<BR>Response.Write rsQuery("Traffic.Customer_Ref")<BR>and get<BR><BR>315 <BR>ADODB.Recordset error &#039 800a0cc1&#039 <BR><BR>Item cannot be found in the collection corresponding to the requested name or ordinal. <BR><BR>Assuming that the SQL procedure is ok. (It worked when we were using ActiveX Controls through VB) and all field names/table names are correct, why can&#039t I write the record set to the screen? Am I missing something obvious?? MSDN suggested a work around based on not putting the passed value in the CreateParameters bit.. But as you can see I&#039ve done that..<BR><BR>Heeeeeeeeeeeeeeeeeeeeeeeelllllllllll llllllllp

  2. #2
    Join Date
    Dec 1969

    Default RE: Stored SQL Procedures and the Recordset Query

    Hi<BR><BR>Instead of getting back the field as "Traffic.Customer_Ref", try giving an alias to it, say "Traffic.Customer_Ref as Customer_Ref" in the query, and then write the value by using the alias name. <BR><BR>Hope this helps.<BR><BR>Cheers<BR>Santhosh<BR>santhosh_arvin

Posting Permissions

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