return new id to asp page - problems

Results 1 to 2 of 2

Thread: return new id to asp page - problems

  1. #1
    Join Date
    Dec 1969

    Default return new id to asp page - problems

    I have a page that creates a new record in the database and instantly returns the unique id - the sytax works in SQL sytax checker but when ran on the page it gives the error :<BR><BR>"Item cannot be found in the collection corresponding to the requested name or ordinal. "<BR><BR>Heres the code from the asp page&#062;<BR><BR>dim objconn<BR>dim objrs<BR>dim strsql<BR>dim strsql2<BR>dim strsql3<BR>dim recordIDvalue<BR><BR>strloanpurpose = request.querystring("loanpurpose")<BR>strloanamoun t = request.querystring("loanamount")<BR>strnumberborr owers = request.querystring("numberborrowers")<BR>strloana pptype = request.querystring("loanapptype")<BR><BR>strsql1 = "Declare @req_num int Exec sp_addproperty " <BR>strsql2 = "&#039;" & request.querystring("state") & "&#039;," & "&#039;" & request.querystring("loanpurpose") & "&#039;," & "&#039;" & request.querystring("loanamount") & "&#039;," & "@req_num OUTPUT"<BR>strsql3 = " select id from applications where id = @req_num"<BR>strsql = strsql1 & strsql2 & strsql3<BR>response.write(strsql) //just to see what the sp is sending<BR>set objconn = server.createobject("adodb.connection")<BR><BR>obj strconn<BR>set objrs = server.createobject("adodb.recordset")<BR>objrs = objconn.execute(strsql)<BR><BR>recordIDvalue = objrs("id")<BR>objconn.close<BR>Set objrs = nothing<BR>set objconn = nothing<BR>%&#062;<BR>done<BR>Your record number is:&#060;%=recordIDvalue%&#062;<BR><BR>... and heres the code from the stored procedure&#062;&#062;<BR><BR>CREATE PROCEDURE sp_addproperty <BR>(<BR> @state nvarchar(2),<BR> @loanpurpose smallint,<BR> @loanamount nvarchar(50),<BR> @req_num int OUTPUT<BR>)<BR>AS<BR><BR>INSERT INTO [applications] (state, loanpurpose, loanamount) VALUES (@state, @loanpurpose, convert(money,@loanamount))<BR>SELECT @REQ_NUM = @@IDENTITY<BR><BR>If anyone has any idea - please let me know - we&#039;ve hit a wall here! <BR><BR>Thanks!!!<BR><BR>Aaron <BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: return new id to asp page - problems

    Have you double-checked all your field and table names? I usually get this error when it can&#039;t find a field or table I&#039;m refering to.

Posting Permissions

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