473,480 Members | 1,663 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

cant get next number

I guess more the fool me for attempting with MS Access but if I execute

select max(nbr) from mytable

nextnbr = maxnbr + 1

insert into mytable (nextnbr...)

multiple times - it appears the first insert is not picked up by the
next select max() - even using the same connection.

Is this due to not having committed i.e. Access query using the same
connection does not show modified data - or is it simply access cannot
register an insert fast enough for the next select?

thanks

Tim

Jun 12 '06 #1
4 2292
If I read you correctly, it sounds like you want to get the next
autonumber. If this is the case, you can't rely on autonum + 1 because
if there is a deletion in the table, that will throw off the
autonumbers. I think that you can only get Identity/Autonumbers from an
enterprise system like sql server, Oracle, ... where they have a
specific object called @@Identity for retrieving the next
Identity/autonumber value. I don't think Access has this capability
since it is not an enterprise system. Maybe I am wrong here - not sure.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 12 '06 #2
Sounds to me like you're doing something wrong.

Try posting real code not meaningless snippets and we mght be able to tell
you where you're going wrong.

--

Terry Kreft
<ti*******@hotmail.com> wrote in message
news:11*********************@h76g2000cwa.googlegro ups.com...
I guess more the fool me for attempting with MS Access but if I execute

select max(nbr) from mytable

nextnbr = maxnbr + 1

insert into mytable (nextnbr...)

multiple times - it appears the first insert is not picked up by the
next select max() - even using the same connection.

Is this due to not having committed i.e. Access query using the same
connection does not show modified data - or is it simply access cannot
register an insert fast enough for the next select?

thanks

Tim

Jun 13 '06 #3
Rich P wrote in message <%o****************@news.uswest.net> :
If I read you correctly, it sounds like you want to get the next
autonumber. If this is the case, you can't rely on autonum + 1
because if there is a deletion in the table, that will throw off the
autonumbers. I think that you can only get Identity/Autonumbers from
an enterprise system like sql server, Oracle, ... where they have a
specific object called @@Identity for retrieving the next
Identity/autonumber value. I don't think Access has this capability
since it is not an enterprise system. Maybe I am wrong here - not
sure.

Rich

*** Sent via Developersdex http://www.developersdex.com ***


With regards to Jet 4.0 and @@identity, have a look here;
http://support.microsoft.com/kb/232144/en-us

--
Roy-Vidar
Jun 13 '06 #4
Thanks. That was a great article. Very informative.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 15 '06 #5

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

Similar topics

1
2381
by: chuck amadi | last post by:
By the way list is there a better way than using the readlines() to > > >parse the mail data into a file , because Im using > > >email.message_from_file it returns > > >all the data i.e reads one...
4
1425
by: nichas | last post by:
the code is ... int main(void){ static int a={1,2,3,4,5}; static int *p={a,a+1,a+2,a+3,a+4}; int i; for(i=0;i<5;i++){ printf("%u\n",a+i);} printf("\n%u\t%u\t%d",p,*p,*(*p)); return 0; } Now...
7
2698
by: Chris Wertman | last post by:
I am so lost on this one. Dim Ary as Integer = New Integer(4) {0,1,2,3} FAILS with the error: Array initializer has 1 too few elements. So I try Dim Ary as Integer = New Integer(3)...
3
1788
by: Kentor | last post by:
hello, im trying to make a little loop, but i cant figure it out... i have a string with a bunch of 1s and 0s in it: 110101010101111010101 .... i need to count the number of 1s divide it by 2 and...
5
1633
by: Ouwet5775 | last post by:
Hello peeps. Well i have tried runing the folwoing program several times, and i cant figure out what i am doing wrong. The goal of this is to input values for an array, find the maximum and the...
0
938
by: riteshraha | last post by:
Hi everyone, I am a member of this forum. i have posted my problem repeatedly to this forum. but i cant get any reply from this forum. plz anyone make any reply of my problem. I cant retrieve...
5
2606
by: Jens | last post by:
Hello, I have been looking for some C-code which listens on a user-defined port for incoming data traffic. When data is received, the data is written to a file. I found some C-code (server)...
7
1452
by: slavisa | last post by:
Hi, im doing a internship with the school and they assigned me couple of projects to do. I created all the tables that i need, with all the relationships etc. Then i created a form with all the...
2
1846
by: ratinox | last post by:
This is the code i was working on. i know it is clunky but im new to this. at the spot that sais RIGHT HERE i am getting this error statement when i try to run it: when casting from a number the...
0
7037
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,...
0
7034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6732
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...
0
5324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4768
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4472
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...
0
2990
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...
1
558
muto222
php
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.