Error when inserting record in SQLite table lazarus / 16-Databases ---------------------------------------------------------------------- JanRoza · 2009-12-20 13:57 I hope someone can help me out as I'm stuck at something using SQLite. When in my program the 'Add record' button is clicked a new record should be inserted in table Vluchten which then can be edited/filled via the programs interface. I've done this many times before in other programs, but now all I get is an error message about converting Null into string. (see attached screenshot Lazarus problem2.jpg) I'm at a loss here as I have the simplest of table structures I can think of: (see attached screenshot Lazarus problem1.jpg) There are no 'Not Null' definitions in my table so why will a statement like tblVluchten.insert give an error like that? I must be overlooking the obvious so hopefully someone fresh can open my eyes. Jan ---------------------------------------------------------------------- LacaK · 2009-12-23 07:07 Hm, I can only say that error is Lazarus error not SQLite error ... So my guess is, that this error happens before an action is performed by SQLite ... try set all varchar columns to 'some string' and then post ... ---------------------------------------------------------------------- JanRoza · 2009-12-23 17:13 The error occurs the moment the 'tblTable1.insert' statement is executed. In the table structure there are no fields that have the 'Not Null' option checked so I would expect the insert to execute without any errors. Only after the insert statement I can start filling in the fields via 'tblTable1.FieldByName' statements, but the error already occurs at the insert, so it must be something that SQLite returns I think. ---------------------------------------------------------------------- davesimplewear · 2009-12-24 00:19 I think your problem relates to the id field, it should be declared as not null and unique as shown below Quotecreate table acc (         accID INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL,    accName   VarChar(50) null ); ---------------------------------------------------------------------- JanRoza · 2009-12-24 11:58 Dave, you're the man! You were right, after changing the table specs the insert goes OK. I knew I had overlooked something simple. Finally I can continue on my project. Thanks again. Jan ---------------------------------------------------------------------- JanRoza · 2009-12-25 12:38 I've been celebrating too soon it seems. The funny thing is that inserting a new record via SQL works okay, but after the insert the dbgrid is not showing the new record (not even after a repaint or a refresh). But doing the insert via statement 'tblTablename.insert' immediately gives the same error message again. I would like to use this method as my grid automatically refreshes this way. So why does inserting via SQL statements work but fails using the table.insert method? If anyone knows a good way to make the dbgrid show the inserted record after SQL insert operations I would be very happy. It's not my first SQLite database job in Lazarus but it's the first one that refuses to work so constantly. Jan