[SOLVED] Adding a record to a table that goes wrong lazarus / 16-Databases ---------------------------------------------------------------------- madref · 2015-11-07 14:38 I am trying to write to a table that i have created like this: 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     // tbl_Seizoenen    cSQL := '';    cSQL := cSQL + 'CREATE TABLE tbl_Seizoenen ';    cSQL := cSQL + '(';    cSQL := cSQL + 'Sei_ID Word PRIMARY KEY ASC,';    cSQL := cSQL + 'SEI_Periode varchar(9),';    cSQL := cSQL + 'Sei_Van Word,';    cSQL := cSQL + 'Sei_Tot Word,';    cSQL := cSQL + 'Sei_Selected Boolean,';    cSQL := cSQL + 'Sei_Letter varchar(2)';    cSQL := cSQL + ');';    Connect_RefereeDB.ExecuteDirect(cSQL);      DecodeDate(Date, y, m, d);    cSQL := 'INSERT INTO tbl_Seizoenen ' +            'VALUES (1,"' + IntToStr(y) + '-' + IntToStr(y+1) + '",' +            IntToStr(y) + ',' + IntToStr(y+1) + ',1,"AA")';    Connect_RefereeDB.ExecuteDirect(cSQL);    Trans_RefereeDB.Commit;Further in the same unit i want to add a new season and i am using this code: 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           // bepaal het laatste seizoen          maxid := strtointdef(MLookup('MAX(Sei_ID)','tbl_Seizoenen','1=1'), 0);        y := MLookup('Sei_Tot','tbl_Seizoenen','Sei_ID='+IntToStr(maxid));        ss := MLookup('Sei_Letter','tbl_Seizoenen','Sei_ID='+IntToStr(maxid));        // De letter A is ASCII 65.          // SS[2] := Dus wordt het 64 + (maxid mod 26) is letter.          // SS[1] := 65 + (maxid DIV 26)        maxid := maxid + 1;          SS := '  ';          SS[2] := CHR(64 + (maxid MOD 26));          SS[1] := CHR(65 + (maxid DIV 26));        // insert recordgegevens met het juiste seizoen en id.          cSQL := 'INSERT INTO tbl_Seizoenen ' +                  'VALUES (' + IntToStr(maxid) + ',"' + IntToStr(y) + '-' + IntToStr(y+1) + '",' +                IntToStr(y) + ',' + IntToStr(y+1) + ',1, "' + SS + '"';          ShowMessage (cSQL);          Connect_RefereeDB.ExecuteDirect(cSQL);          Trans_RefereeDB.Commit;          Showmessage('Season ' + IntToStr(y) + '-' + IntToStr(y+1) + CHR(10)+CHR(13) +                      'Sortingletters: ' + SS);But when i run the code i get an error on the Connect_Referee..... What am i (again) doing wrong? ---------------------------------------------------------------------- madref · 2015-11-08 11:14 Found out what the problem was.... i forgot a closing bracket at the end 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 cSQL := 'INSERT INTO tbl_Seizoenen ' + 'VALUES (' + IntToStr(maxid) + ',"' + IntToStr(y) + '-' + IntToStr(y+1) + '",'  + IntToStr(y) + ',' + IntToStr(y+1) + ',1, "' + SS + '")';