I need help about this issue. There is a problem but I could not find it
error message is
Cannot add or update a child row: a foreign key constraint fails (
db_kiosk
.tbl_oyunhareketi
, CONSTRAINTOH_KioskID
FOREIGN KEY (OH_KioskID
) REFERENCEStbl_kiosk
(Kiosk_ID
) ON DELETE NO ACTION ON UPDATE NO ACTION)
Here is my code c#
string sql = "insert into db_kiosk.tbl_oyunhareketi (OH_OyuncuID,OH_KioskID,OH_Puan,OH_Tarih,OH_ControlRow) values ('"+Convert.ToInt32(Label4.Text)+"','"+Convert.ToInt32(Label3.Text)+"','" + Puan_txt.Text + "' , '" + Tarih_txt.Text + "',1)";
Label3.Text = Kiosk_Drop.SelectedValue;
Label4.Text = Oyuncu_Drop.SelectedValue;
Kiosk_Drop
and Oyuncu_Drop
are the dropdownlist in ASP.net and they are in the selectedIndexChanged
function. When I display the labels the values are coming properly but problem is insertion. DB attributes also integer
but I couldn't find the problem.