🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #4624

[VB6] id van laatste insert in database

#4624
From: Robrecht Jacques
Date: Thu, 17 Jul 2003 15:42
24 lines
1590 bytes
Hallo,

hoe kan ik de ID van de laatste INSERT (SQL) in een database bekomen? Ik
gebruik (enkel relevante code):

  dim db as connection
  dim sql as string

  set db = new connection
  db.open "DRIVER={Microsoft Access Driver (*.mdb)};" & _
          "DBQ=c:/path/to/data.mdb;" & _
          "Exclusive=1"
  sql = "INSERT INTO Table (Field1, Field2) " & _
        "VALUES ('Value1', 'Value2')"
  db.execute sql
  db.close
  set db = nothing

De tabel 'Table' heeft daarnaast nog een auto-increment field (als primary
key): Id1. Nu zou ik graag de waarde van die Id1 hebben voor een volgende
insert.

Thx,
Robrecht
Technical Details
Message-ID: <3f16c490$0$304$ba620e4c@reader1.news.skynet.be>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!skynet.be!skynet.be!louie!tlk!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: fcea4,b4fd27c755461f8b,start
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-07-17 08:45:49 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!priapus.visi.com!news-out.visi.com!petbe.visi.com!skynet.be!skynet.be!louie!tlk!not-for-mail
From: "Robrecht Jacques" <Robrecht.Jacques@advalvas.be>
Newsgroups: be.comp.programming
Subject: [VB6] id van laatste insert in database
Date: Thu, 17 Jul 2003 17:42:23 +0200
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Lines: 27
Message-ID: <3f16c490$0$304$ba620e4c@reader1.news.skynet.be>
Organization: -= Belgacom Usenet Service =-
NNTP-Posting-Host: 217.136.91.232
X-Trace: 1058456720 reader1.news.skynet.be 304 217.136.91.232:1037
X-Complaints-To: usenet-abuse@skynet.be