This is the error i get Cannot add or update a child row:
a foreign key constraint fails (selo.klijent, CONSTRAINT klijent_ibfk_1 FOREIGN KEY (GradID) REFERENCES grad (GradID))
this is my insert query
string insertQuery = " INSERT INTO selo.Klijent(KlijentID,Ime,Prezime,Adresa,GradID,Telefon,Email,AktivanKlijent) Values('" + TB_Sifra + "','" + TB_Ime.Text + "','" + TB_Prezime.Text + "','" + TB_Adresa.Text + "','" + CB_Gradovi + "','" + TB_Telefon + "','" + TB_Mail.Text + "','" + proveraRB() + "')";
and this is my mysql code
create table Klijent(
KlijentID INT NOT NULL AUTO_INCREMENT primary key,
Ime varchar(20) not null,
Prezime varchar(20) not null,
Adresa varchar(20) not null,
GradID INT NOT NULL,
Telefon int not null,
Email varchar(20),
AktivanKlijent varchar(2),
FOREIGN KEY (GradID) REFERENCES Grad(GradID)
);
Really not sure what to do here