Hi all. I have run into a problem with inserting values into table.
I have 2 tables: PUBLISHER with fields: PUBLISHER_CODE (Primary Key) and PUBLISHER_NAME. BOOK table fields: PUBLISHER_CODE (Primary Key and Foreign key to PUBLISHER table) and TITLE.
The user enters bookCode and publisherName into 2 textboxes
Here is the code for inserting:
"INSERT INTO BOOK (TITLE) VALUES(@bookCode)";
"INSERT INTO PUBLISHER (PUBLISHER_NAME) VALUES(@publisherName)";
When running programme, the PUBLISHER table generates a new PUBLISHER_CODE (Primary Key) and publisherName inserted.
Now problem is for the BOOK table the following error appears:
"Cannot insert the value NULL into column 'PUBLISHER_CODE'", table BOOK
Why is this happening? Doesnt BOOK generate same/new PUBLISHER_CODE from PUBLISHER table since its a foreign key?