[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


How do I get the unique id from my table when a new row is added to my dataset

Posted on 2008-11-19
Medium Priority
Last Modified: 2013-11-26
Please bear with me as I am new to Visual Basic.  I'm using Visual Studio to develop a Windows application.  The database I am connecting to is MS Access.  I can successfully add new records to the database.  What I now need to do is each time I add a new employee to the database, I want to retrieve the unique id (ID autonumber) from the just added record so I can use it to add a "History" record to another table that maps back to the new employee.  I will be adding a lot of employees so I want to wait until all of the employees have been added to the dataset before I update the physical database using the following code:  Me.EmployeeTableAdapter.Update(Me.HWDataSet.Employee).

What I need is the code that will retrieve the unique id generated from the Me.HWDataSet.Employee.Rows.Add(EmployeeRow) call.

Any help would be greatly appreciated!
Dim EmployeeRow As HWDataSet.EmployeeRow
' Insert Employee into dataset
Catch ex As Exception
End Try

Open in new window

Question by:dyarosh
LVL 15

Accepted Solution

JackOfPH earned 1500 total points
ID: 23001242
Follow the link from Microsoft.. :)


Author Comment

ID: 23002715
Thanks for the link.  The article runs the Identity Select after an Update() is called.  I was hoping to hold off on calling Update() until after all of the records have been loaded into the dataset.  Is there a way to do this?

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month19 days, 6 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question