Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - retrieve Database ID
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

retrieve Database ID

 Post Reply Post Reply
Author
288enzo View Drop Down
Groupie
Groupie
Avatar

Joined: 28 April 2003
Location: United States
Status: Offline
Points: 61
Post Options Post Options   Thanks (0) Thanks(0)   Quote 288enzo Quote  Post ReplyReply Direct Link To This Post Topic: retrieve Database ID
    Posted: 16 May 2003 at 8:30pm

On my page that posts all data to my database I have added the following in hopes to see what the number was of the new record I just added.

rsAddListing.Update

intIDNumber = request.form("id")

response.write "New record number is " & intIDNumber

My problem is that I don't get the new record number to appear.  Is there some sort of trick that I am missing.  Please help...

 

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 10:10pm

You need to get the ID from the database, not the querystring.

Do a search for @@IDENTITY on google. Should help you out.

Cheers,
Andrew

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
288enzo View Drop Down
Groupie
Groupie
Avatar

Joined: 28 April 2003
Location: United States
Status: Offline
Points: 61
Post Options Post Options   Thanks (0) Thanks(0)   Quote 288enzo Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2003 at 10:18pm
I'm sorry, I forgot to mention that I tried @@Identity already and had no success.
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 12:37am

If you're using Access 2000+ or SQL Server then you're doing it wrong.

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
288enzo View Drop Down
Groupie
Groupie
Avatar

Joined: 28 April 2003
Location: United States
Status: Offline
Points: 61
Post Options Post Options   Thanks (0) Thanks(0)   Quote 288enzo Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 8:39am
Bunce, I am using Access 2002.  What is it that I am doing wrong?
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 8:49am

How are we meant to know without showing us your code!!

Have you searched the many articles on the net for the code to do what you want?  There are HEAPS of examples.

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
288enzo View Drop Down
Groupie
Groupie
Avatar

Joined: 28 April 2003
Location: United States
Status: Offline
Points: 61
Post Options Post Options   Thanks (0) Thanks(0)   Quote 288enzo Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 6:24pm

I have tried many, many, many different ways of doing this.  I have been to many, many different web sites that offer code and nothing is working.

My code:

<%
Dim adoCon    
Dim rsAddListing  
Dim strSQL   
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("..........")
Set rsAddListing = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT tblListings.ID, tblListings.city, tblListings.structure FROM tblListings;"
rsAddListing.CursorType = 2
rsAddListing.LockType = 3
rsAddListing.Open strSQL, adoCon
rsAddListing.AddNew
rsAddListing.Fields("city") = Request.Form("city")
rsAddListing.Fields("structure") = Request.Form("structure")
rsAddListing.Update

intIDNumber = rsAddListing.Fields("ID")

response.write "before " & intIDNumber & " after"

Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = ".........."
objNewMail.To = request.form("email")
objNewMail.Subject = "New Listing #" & intIDNumber
objNewMail.Body = "....."
objNewMail.Send
Set objNewMail = Nothing

rsAddListing.Close

Set rsAddListing = Nothing
adoCon.Close
Set adoCon = Nothing

%><head><title>Post New Listing to Database</title></head>

Back to Top
288enzo View Drop Down
Groupie
Groupie
Avatar

Joined: 28 April 2003
Location: United States
Status: Offline
Points: 61
Post Options Post Options   Thanks (0) Thanks(0)   Quote 288enzo Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2003 at 8:53pm

Thanks everyone, but I figured it out.  All I needed to do was add the following after my update statement.

rsAddListing.movelast

and that did it.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.