Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Multiple Tables in MS Access Database !

Multiple Tables in MS Access Database !

Scheduled Pinned Locked Moved Database
helptutorialcsharpdatabase
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jeshra279
    wrote on last edited by
    #1

    Hi Everyone, I am using MS Access database with VB.NET. My problem is very simple. It is as follows: I have two tables "Class" ( with a field "Class") & "Section"( with a field "Section"). I can fill both this tables of MS Access database programmaticaly thorough VB.NET. There are two textboxes t1 & t2 on the Form to fill corresponding fields "Class" & "Section" of the tables. Now what I want is to fill "Class" field and then "Section" field in such a way that for each entry of "Class" field, there will be entry in "Section" field. e.g. Insert class 1 in textbox t1 Insert setion A in textbox t2 While save, section A must be saved under class 1. Similarly, if I Insert class 1 in textbox t1 Insert section B in textbox t2 then, section B should come under class 1. Similarly, if I insert class 2 and then section A & section B, then both this sections should get stored under class 2. Overall, there should not be any conflict between class and section entries. i.e. each class entries has its corresponding section entries. Hope My issue is clearly. Can someone help me how to do this? Any example would be appreciated. Regards R.S.

    M 1 Reply Last reply
    0
    • J jeshra279

      Hi Everyone, I am using MS Access database with VB.NET. My problem is very simple. It is as follows: I have two tables "Class" ( with a field "Class") & "Section"( with a field "Section"). I can fill both this tables of MS Access database programmaticaly thorough VB.NET. There are two textboxes t1 & t2 on the Form to fill corresponding fields "Class" & "Section" of the tables. Now what I want is to fill "Class" field and then "Section" field in such a way that for each entry of "Class" field, there will be entry in "Section" field. e.g. Insert class 1 in textbox t1 Insert setion A in textbox t2 While save, section A must be saved under class 1. Similarly, if I Insert class 1 in textbox t1 Insert section B in textbox t2 then, section B should come under class 1. Similarly, if I insert class 2 and then section A & section B, then both this sections should get stored under class 2. Overall, there should not be any conflict between class and section entries. i.e. each class entries has its corresponding section entries. Hope My issue is clearly. Can someone help me how to do this? Any example would be appreciated. Regards R.S.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      I think you are referring to referential integrity and how to create and maintain a relationship between class and section. In your tables you need to have key fields something like this ClassID Class SectionID ClassID Section ClassID and SectionID are auto increment field and are the primary keys to their tables. When you insert a record in the Class table you should get back the ClassID from the insert method (in SQL Server it is with @@Identity or @Scope_Identity). You now need to use this ClassID when inserting the record into the Section table. Generally these type of linked inserts are wrapped in a transaction so if a Class insert fails then you do not insert a Section record with no related Class record. I suggest you get a book on databases and start working through the examples, you will struggle if you try to use a forum for your primary learning tool.

      Never underestimate the power of human stupidity RAH

      J 1 Reply Last reply
      0
      • M Mycroft Holmes

        I think you are referring to referential integrity and how to create and maintain a relationship between class and section. In your tables you need to have key fields something like this ClassID Class SectionID ClassID Section ClassID and SectionID are auto increment field and are the primary keys to their tables. When you insert a record in the Class table you should get back the ClassID from the insert method (in SQL Server it is with @@Identity or @Scope_Identity). You now need to use this ClassID when inserting the record into the Section table. Generally these type of linked inserts are wrapped in a transaction so if a Class insert fails then you do not insert a Section record with no related Class record. I suggest you get a book on databases and start working through the examples, you will struggle if you try to use a forum for your primary learning tool.

        Never underestimate the power of human stupidity RAH

        J Offline
        J Offline
        jeshra279
        wrote on last edited by
        #3

        Thanks....Any sample example/link will be appriciated.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups