Home | Advertising Info19 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Monday, May 06, 2024  

  Active InfoActive Info  Display List of Info MembersMemberlist  Search The InfoSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Info: @@Identity and Recordsets A d d  -  P o s tAdd P o s t
Author
Message << Prev Info | Next Info >>
amardilo
Newbie
Newbie


Joined: January/31/2006
Online Status: Offline
Info: 1
Added: January/31/2006 at 10:17am | IP Logged Quote amardilo

Hi,

I am new here but I was wondering if anyone could answer a question for me as I am in need of urgent help.

I am writting an application in classic ASP (well its un upgrade to an application already created in ASP and MS SQL Server 2000).

Anyway I am trying to get the ID of a row I just inserted into a database table, but when I run my code my SQL code runs and does the insert (I ran a test using MS SQL profiler) and the ID is returned but my recordset seems to run into errors after that.

I get an error saying that the recordset is already closed

Here is my code

 set objConn = Server.CreateObject("ADODB.Connection")
 set objRs = Server.CreateObject("ADODB.Recordset")

 objConn.Open strConnect

 strSQL = "DECLARE @test_ID INT; INSERT INTO myTable VALUES ('myCol', 'myCol'); SELECT @test_ID = @@IDENTITY; SELECT @test_ID AS test_ID"
 
 objRs.open strSQL, objConn
 
 if NOT (objRs.EOF AND objRs.BOF) then
  intID = objRs("test_ID")

The error occours on the if statment (if I get rid of the if statement I get an error saying the operation does not exist).

Anyone got any idea's?

Back to Top View amardilo's Profile Search for other info by amardilo Visit amardilo's Homepage
 
firas_TheGeek
Newbie
Newbie
Avatar

Joined: May/27/2006
Location: Oman
Online Status: Offline
Info: 28
Added: May/27/2006 at 8:04am | IP Logged Quote firas_TheGeek

i dont recognize ur SQL Statment

but are you sure its correct

i have another way doing this and always works fine

Dim test_ID
objrs.open myTable, objconn,2,3
objrs.addnew
objrs.fields("Col1")="myCol"
objrs.fields("Col2")="myCol"
objrs.update

test_ID=objrs.fields("ID")

 

hope it works

tell me what happens with u

 

Best Regards



__________________
Firas S Assaad (TheGeek)
firas489@gmail.com
0096892166434
http://firas-thegeek.blogspot.com
Back to Top View firas_TheGeek's Profile Search for other info by firas_TheGeek Visit firas_TheGeek's Homepage
 

If you wish to make a comment to this info you must first login
If you are not already registered you must first register

  A d d  -  P o s tAdd P o s t
Printable version Printable version

Info Jump
You cannot add new info in this area
You cannot add to info in this area
You cannot delete your info in this area
You cannot edit your info in this area
You cannot create polls in this area
You cannot vote in polls in this area

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2024 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages asp search engine active server page asp application components tutorial CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com