473,803 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get autonumber column value

Hi,

I am inserting records into a table having a autonumber column(ID) as
primary key. I get the value of ID by using select Max(ID) from table. Is
there any way to retieve the value immediately after inserting the record
without another query (like in ado). Any tutorials with example would be
great

Thanks

Srinivas
Nov 20 '05 #1
2 1423
Srinivas,
This depends on the type of database used. See
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/cpguide/html/cpconretrieving i
dentityorautonu mbervalues.htm
in the VS.NET help files on "Retreiving Identity or Autonumber Values" (or
search for this in MSDN online).

Ron Allen
"Reddy" <an********@NO. JUNK.MAIL> wrote in message
news:O2******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

I am inserting records into a table having a autonumber column(ID) as
primary key. I get the value of ID by using select Max(ID) from table. Is
there any way to retieve the value immediately after inserting the record
without another query (like in ado). Any tutorials with example would be
great

Thanks

Srinivas

Nov 20 '05 #2
On Tue, 13 Jan 2004 11:53:46 -0000, "Reddy" <an********@NO. JUNK.MAIL> wrote:

¤ Hi,
¤
¤ I am inserting records into a table having a autonumber column(ID) as
¤ primary key. I get the value of ID by using select Max(ID) from table. Is
¤ there any way to retieve the value immediately after inserting the record
¤ without another query (like in ado). Any tutorials with example would be
¤ great

No, it requires a bit of effort.

http://longhorn.msdn.microsoft.com/l...bervalues.aspx
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
19935
by: Roger Withnell | last post by:
I'm inserting a new record into an MS SQL database table and I want to obtain the new records autonumber immediately afterwards, as follows: MadminRS.CursorLocation = adUseServer MadminRS.CursorType = adOpenKeyset MadminRS.LockType = adLockOptimistic MadminRS.Open "NavBar", objConn, , , adCmdTable MadminRS.AddNew MadminRS("Url") = Request.Form("Website") MadminRS("ParentRecNo") = 0
5
1801
by: Lapchien | last post by:
Our database has a field called 'Card' which records the transaction reference number. This is generated as an autonumber. Not the best way at all - I know, having picked this up in the last few months. We do not want to use 7 numbers for this, and would like to know if we can generate the Card number by 'picking up' any of the 'missing' Card autonumbers in the Card field? (autonumber having missed an awful lot of insertions)... I...
33
4326
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and setting default value to a UDF that manages the auto-numbering. Access won't take a UDF as a default value. Okay, I'll use SQL WITHOUT any aggregate functions, for the default value. Access won't do that either. Okay, I create a second...
2
4767
by: Ed Havelaar | last post by:
Hi, Hope someone can help. Here's the scenario: I have two MSAccess tables MainTab and SubTab. MainTab has an autonumber 'id' column as primary key. Subtab has this id column as a foreign key. There is a one-to-many relationship defined on MainTab and Subtab using the id column. The join type is include all from MainTab and only rows with matching value from SubTab. Referential integrity enforced; cascading
35
7280
by: Traci | last post by:
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key start at 51 after the last 50 records are deleted? Thanks! Traci
5
3059
by: Apple | last post by:
May anyone can teach me how to assign a autonumber, I want to create a number that is starting with year(auto change to year 2006) + autonumber (eg. 2005-0001, 2005-0002)
2
1753
by: Materialised | last post by:
Hi All, I am writing a program in C, which will be driving via a MS Access database. I am relitivly new to database design, so if anyone could help me with my issue I would be greatful. I have defined a database field to be a primary Key, this field is set to contain the AutoNumber data type. I would like to know if it is possible to start the autonumber sequence from a number other than 0.
11
4501
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any AutoNumber* fields in them. Correct me if I'm wrong, but I'm assuming this means that I cannot now alter these existing Access tables and change their primary key to an "AutoNumber" type. If I'm right about this, I need some suggestions as to the...
4
5376
by: lamkelf | last post by:
Hi all, I have found solution for previous Access versions (i.e. compacting database) but it doesn't work with the 2003 version. Can someone point me to a website or give me some hints. Thanks!!!!!! KL
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10289
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.