Results 1 to 5 of 5

Thread: Adding new record in relational AccessDB with ADO.net

  1. #1

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    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

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  2. #2
    Addicted Member craigreilly's Avatar
    Join Date
    Jul 2004
    Location
    Scottsdale, AZ
    Posts
    188
    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?

  3. #3
    Lively Member
    Join Date
    Jan 2002
    Posts
    105
    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.

  4. #4
    Addicted Member craigreilly's Avatar
    Join Date
    Jul 2004
    Location
    Scottsdale, AZ
    Posts
    188
    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?

  5. #5
    Lively Member
    Join Date
    Jan 2002
    Posts
    105
    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
  •  



Click Here to Expand Forum to Full Width