DBLookupCombobox can not convert null to int64 for data submission lazarus / 16-Databases ---------------------------------------------------------------------- asimkon · 2020-06-10 08:03 I have been using Lazarus 2.x with Firebird 3 (via flamerobin) and i try to commit records into a table with a foreign key via TSQLConnection, TSQLQuery, TDataSource (data module). I run the following script successfully in order to configure initially DBLookupCombobox (reference table) and the records are displayed without any problem from table1. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm3.FormCreate(Sender: TObject);  begin  appeals.SQLQuery4.Close;  appeals.SQLQuery4.SQL.Text:='select id,fullname from promoter';   appeals.SQLQuery4.Open;   appeals.DataSource2.DataSet:=appeals.SQLQuery4;  DBLookupComboBox1.ListSource:=appeals.DataSource2;  DBLookupComboBox1.ScrollListDataset:=True;  DBLookupComboBox1.Style:=csDropDownList;  DBLookupComboBox1.KeyField:='id';  DBLookupComboBox1.DataField:='id';  DBLookupComboBox1.ListField:='fullname';       end; Afterwards i use the following script to submit all selected data to table2 with foreign key Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm3.Button1Click(Sender: TObject);begin   appeals.SQLTransaction1.Active:=false;   appeals.SQLQuery1.SQL.Text:='UPDATE appeals set name=:name,date_entry=:entry,date_suspended=:suspended,'+  'date_court=:court,date_judgement=:judgement,promoter_id=:code where id='+IntToStr(row_num);   appeals.SQLQuery1.Params.ParamByName('name') .AsString:=Trim(Edit1.Text);  appeals.SQLQuery1.Params.ParamByName('en try').AsDate:=DateTimePicker1.Date;  appeals.SQLQuery1.Params.ParamByN ame('suspended').AsDate:=IncDay(DateTimePicker1.Date,10);  appeals.SQL Query1.Params.ParamByName('court').AsDate:=DateTimePicker2.Date;  appe als.SQLQuery1.Params.ParamByName('judgement').AsDate:=IncDay(DateTimeP icker2.Date,20);  appeals.SQLQuery1.Params.ParamByName('code').AsInteg er:=DBLookupComboBox1.KeyValue;   appeals.SQLTransaction1.StartTransaction;  appeals.SQLQuery1.ExecSQL;  appeals.SQLTransaction1.Commit;  Application.MessageBox('Record submission with success !', 'Information', MB_ICONINFORMATION);                               end; Unfortunately i receive the following error ( attached as image) that has to do with Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i appeals.SQL Query1.Params.ParamByName('code').AsInteger:=DBLookupComboBox1.KeyValu e; I try to submit data via edit, datetimepicker and DBLookupCombobox as foreign key to a table (attached as image). Any help would be convenient to me! Regards ---------------------------------------------------------------------- rvk · 2020-06-10 10:16 At the top of the buttonclick you close the transaction of appeals.SQLQuery4. This will effectively close the dataset. Because DBLookupComboBox1 is connected to that dataset (via ListSource), you also set the Keyvalue of DBLookupComboBox1 to null. After that you try to assign a null to a asInteger (which isn't possible because null isn't a number). I'm not sure what you are trying to do with the DBLookupComboBox but you could first save the code (or  DBLookupComboBox1.KeyValue) before closing the transaction. Then you can assign that saved value to asInteger. But as I see it in the code... you don't want your code field to change, do you? You UPDATE a record and want to assign 'code' field with the same value as the DBLookComboBox (which has the previous valie). So why don't you just remove de code assignment in the UPDATE statement ??