473,324 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Finding the Primary Key of a Just added record.

Hi,
I have a Web app using VS.Net 2003, ASP and VB. I am using RDO with a SQL
Server 2000 database. The code below shows an example of a NewRow method.
In the first column there is a integer field that is set as the primary key
and with Identity (1,1)
rRow1 = iDataSetA.Tables("tCurSessions").NewRow()

rRow1("sesSessionCnt") = 0

rRow1("sesSessionStart") = Now()

rRow1("sesSessionStop") = Now()

rRow1("sesSessionSecs") = 0

rRow1("sesUserUnq") = 0

rRow1("sesUserTyp") = 0

rRow1("sesUserIDX") = 0

rRow1("sesUserZipUnq") = 0

iDataSetA.Tables("tCurSessions").Rows.Add(rRow1)

iAdapCurSess.Update(iDataSetA, "tCurSessions")

After this Adaptor Update to the server is there a way that I can easily get
the value of that primary key of that record that I just added.

thanks,

hugh
Nov 21 '05 #1
2 1096
Hi Hugh,

Here is a KB, I think that is what you want.
320141 HOW TO: Retrieve an Identity Value from a Newly Inserted Record from
SQL
http://support.microsoft.com/?id=320141

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2
Peter,
Thank you.

I was hoping that there might be another option than simply passing the
data. But you have confirmed what I thought. My app may need to
re-retrieve that new record soon after it is written. That could be
inefficient when I do not know the key. I guess I can do it with another
index but was hoping to avoid that.

Thanks for the response.
hugh
""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:PL****************@TK2MSFTNGXA01.phx.gbl...
Hi Hugh,

Here is a KB, I think that is what you want.
320141 HOW TO: Retrieve an Identity Value from a Newly Inserted Record
from
SQL
http://support.microsoft.com/?id=320141

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #3

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

Similar topics

6
by: Gabriel Harrison | last post by:
Hi, I have a mysql db with with autoincrementing primary keys in each table. I want to allow a user to add a record using a php webpage. Once the page is added how can I re SELECT that record...
8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
6
by: Andreas | last post by:
Hello list, what about uniqueness of inherited primary keys ? eg you have : create table objects ( id int4, date_created timestamp(0), primary key (id)
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
2
by: stranger | last post by:
My database is set up so people can input parts orders. Sometimes they order the same parts on a monthly basis. I want to be able to duplicate past parts orders and have it pasted in with a new...
3
by: Newbie | last post by:
Could someone please tell me how or if the following is possible. I have created a small test database and have opened one connection, one DataAdapter, and one Dataset for it in my vb.net...
13
by: pb648174 | last post by:
Whenever I want help on a query, I get told my design is wrong, So this time I'm posting a message during the design phase: How am I going to perfectly design the following? We want to be able...
3
by: DavidB | last post by:
New to .net....sorry if this seems repetitive I have a dataset ordered by date (SQLDataAdapter SelectCommand uses Order By) and want to find a record by a UniqueID(Identity Column). Then I want...
1
by: Pedro Pinto | last post by:
I'm new at access and i'm dealling with a simple problem on positioning the form record seeking a date primary field. I have simple table with two data fields: 1- date field as short-date...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.