|
-
Jun 25th, 2004, 09:00 AM
#1
Thread Starter
Frenzied Member
Adding new record in relational AccessDB with ADO.net
i'm working on this access DB that has the following tables, fields (I need), and primary and forigen keys.
** = primary key
* = forigen
- = field.
Library Information
** ID
- Library Name
- Address1
- Address2
- City
- State
- Zip
- Library Type
Library Project
** PROJ_ID
* LIB_ID
- proj_name
- proj_budget
Shipping Log
** SLT_ID
* PROJ_ID
- ship_date
- attetion_of
- cd_cs_person
- lst_pricing
- spec_notes
Shipping Log List
** LST_NAME_ID
* SLT_ID
- list_name
- titles_on_lst
- list_amt
all the primary keys are Autonumbers. If i pull these tables into a dataset and add new records to the dataset and then load the dataset back into the database, what happens with the primary keys that are autonumbers? does ado.net know or somehow make the autonumber, and what about if someone else is also adding. sorry about all the questions. but like i said before with many of my post i'm still learning, so please bear with me...and thanx for any and all help
-
Jul 13th, 2004, 09:16 PM
#2
Addicted Member
in VB 6, the autonumber happened automatically when updating an Access Db. I imagine .NEt is the same.
My question - When I create a new record (ie: customer), I want to be able to open that record immediately for additiona fields. How do I know what autonumber was assigned to it so I can retrieve it?
-
Jul 14th, 2004, 05:59 AM
#3
Lively Member
Yes .NET just "knows" about it. Thats what i've found if using dataviews.
craigreilly:
You'll have to reload your data after inserting a new record to gain access to the new id field.
-
Jul 14th, 2004, 07:25 PM
#4
Addicted Member
So If I want to keep my form open after creating a new record - the best way might be to compare field.jobname to database.jobname and field.address to database.address, etc to make sure it loads the exact one, and not a similar one... then look up the autonumber id and use that from then on?
-
Jul 15th, 2004, 06:00 AM
#5
Lively Member
I do it by clearing the dataset and then refill the dataadapters, ect, ect
I've put all the create dataadapters and datasets, ect in a function called LoadData and then when i have to i clear the dataset and call the LoadData function, this way seems to work ok, not sure if it's right or not.
I cant see anyway of doing it without reloading your data first if you need to access the autonumber ID field.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|