View Single Post
  #5 (permalink)  
Old June 30th, 2009, 03:54 PM
slake slake is offline
Authorized User
 
Join Date: Jun 2009
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default FOREIGN KEY NOT INPUT IN TABLE FROM VB.NET

hi there
Really gald you could answer so promptly. This is the scenario

Cust(C_id,CName,Address) , Book(B_id,Title,Author,C_id). Now these are my two table. I am inserting data into from my form in VB. I do not have any text boxes for the primary keys as they are both identity columns. When i insert the CName,Address then Title,Author from the text boxes in VB the info is saved and primary keys for both tables created.
However. I need to have the Primary key of the Cust table automatically inserted into the Book table as a foreign key. For example

Cust(1,J.Smith,45 london str) Book(11,The drive,M.Andrews,1). In this eample i know the the primary keys will auto generate when the data in inserted but 1 will not appear as a foreign key in Book unless i go back into the table and manually insert it. In my case i need to create some from of function to insert it for me everytime insert data into my tables. My user needs to only enter the required data and not bother about primary or foreign keys . I read about triggers that can be created in the database. Im not sure if this will work and if it does how do i write one(Please advise with an example) or if there is any other way of doing it.Please advise.

Thanks again in advance. i appreciate the help.

Kind regards

Slake
Reply With Quote