lundi 28 décembre 2015

Error "Foreign Key mismatch" when trying to insert data into a linking table

here's my error, http://ift.tt/1QXco04 ,completely unsure how it's occuring. Pretty sure the reason for the error is somewhere in my linking table, here it is, http://ift.tt/1PtLycC (sqlite), tried everything and still not working, please if you can throw me a solution. Thanks

Here's the code for the query.

    val1:= random(500);
 edtcustid.Text:=inttostr(val1);
    con := TFDConnection.Create(nil);
    insertquery := tfdquery.Create(con);
    insertquery.Connection := con;
    con.DriverName := 'SQL';
    con.Open('DriverID=SQLite;Database=' + dir + '/Stock_V5;');
    ShowMessage('Current directory = '+dir);
  insertquery.SQL.Text :=
      'INSERT INTO Order2(OrderID, Product_Name, Quantity, Customer_Name, Date)'
      + 'VALUES (:OID, :PN, :Q, :CN, :D)';
      showmessage('1');
      insertquery.ParamByName('OID').AsString := edtcustid.Text;
      insertquery.ParamByName('PN').AsString := edtproductname.Text;
      insertquery.ParamByName('Q').AsString := productquantity.Text;
      insertquery.ParamByName('CN').AsString := edtcustomername.Text;
      insertquery.ParamByName('D').AsString := datetostr(datetimepicker1.Date);
    showmessage('2');
    insertquery.ExecSQL;

Aucun commentaire:

Enregistrer un commentaire