Recent

Author Topic: Error in the Insert/Post methods for SQLite 3?  (Read 4156 times)

nightrider

  • Full Member
  • ***
  • Posts: 139
Error in the Insert/Post methods for SQLite 3?
« on: September 26, 2011, 12:34:07 am »
I ran the simple code showed below and nothing happens with the table "tblpar" in the database associated with SQLite3Dataset named "cdsTeste".

If I transform the code from cdsTeste.Insert thru ShowMessage in comments and remove the comment in the cdsTeste.ExecuteDirect, the database is updated successfully and a new row appears in it.

Can someone of you explain what's happen here, please? I'm using Lazarus 0.9.30 with SQLite 3 in windows 7. But I pretend to execute the application in windows mobile as soon as I solve this problem.

Code mentioned above:


procedure TForm1.Button1Click(Sender: TObject);
begin
  cdsTeste.SQL := 'select * from tblpar where cdemp = -69';
  try
    cdsTeste.Open;
  except
    On e:Exception do
       begin;
         ShowMessage('Erro open = '+  e.Message);
         Halt;
       end;
  end;
  if cdsTeste.RecordCount > 0  then
     begin;
       ShowMessage('Record count inesperado = ' + IntToStr(cdsTeste.RecordCount));
       Halt;
     end;
  cdsTeste.Insert;
  cdsTeste.FieldByName('cdemp').AsInteger := 6969;
  cdsTeste.FieldByName('dsnomecom').AsString := 'fhasjfhsjfhksfhsjkfsdjkfns dfa';
  cdsTeste.FieldByname('dspath').Clear;
  cdsTeste.Post;
  ShowMessage(BoolToStr(cdsTeste.ApplyUpdates));
//  cdsTeste.ExecuteDirect('insert into tblpar(cdemp,dsnomecom,dspath) values(6969,''fhasjfhsjfhksfhsjkfsdjkfns dfa'',null)');
end;   

Greetings from Sao Paulo - Brasil

Ricardo

Lacak2

  • Guest
Re: Error in the Insert/Post methods for SQLite 3?
« Reply #1 on: September 26, 2011, 07:58:50 am »
May be, that problem is in
"After applying the updates, a commit must be executed to save the changes on the database server."

See: http://wiki.lazarus.freepascal.org/SqlDBHowto#How_to_change_data_in_a_table.3F

nightrider

  • Full Member
  • ***
  • Posts: 139
Re: Error in the Insert/Post methods for SQLite 3?
« Reply #2 on: September 26, 2011, 02:08:51 pm »
It seems that the behavior of TSQLite3DataSet isn't similar of that of TSQLQuery and some properties and methods of TSQLQuery doesn't exist in TSQLite3Dataset.

For example the property Upda]"]>Blockedde isn't recognized by TSQLite3Dataset objects.

Cheers

Ricardo

 

TinyPortal © 2005-2018