myCommand = New SqlCommand(
"INSERT INTO tblBook(BookCode, BookTitle, Author, PublishingYear,
Price, EnterDate, CatID, RackID, Amount)
VALUES('" & txtBookCode.Text & "','" &
txtTitle.Text & "','" &
txtAuthor.Text & "','" &
txtPublishYear.Text & "','" &
txtPrice.Text & "', #" &
txtEnterDate.Text & "#, " &
txtCategory.ValueMember & "," &
txtRack.ValueMember & "," &
txtAmount.Text & ")"
, myConnection)
The error was:
The INSERT statement conflicted with the FOREING KEY constraint "FK_tblBook_tblCategory". The conflict occurred in database "CIEDC", table "dbo.tblCategory", column 'CatID'. The statement has been terminated.
Was that because of my database's relationships?
How can this be solved?