Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-05

Newbe sqlite problem

8 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Paul van der Vlis

Hello list,

When I do a "select" in my sqlite query everything works fine. But when I do a "update" I get an error:
----
list index (-1) out of bounds.
Press OK to ignore and risk datacorruption. Press cancel to kill the program.
---

What will be wrong?

With regards,
Paul van der Vlis.

the code:
-------------------------
unit atc_unit1;

{$mode objfpc}{$H+}
interface

uses
Classes, SysUtils, LResources, Forms, db, sqlite3ds, DBGrids, DbCtrls, sqldb;

type
  { TxxxSqliteForm }
  TxxxSqliteForm = class(TForm)
    xxxDataset: TSqlite3Dataset;
    xxxDatasource: TDatasource;
    xxxGrid: TDBGrid;
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;
var
  xxxSqliteForm: TxxxSqliteForm;
implementation
procedure TxxxSqliteForm.FormDestroy(Sender: TObject);
begin
  xxxDataset.Close;
end;
procedure TxxxSqliteForm.FormCreate(Sender: TObject);
var query : string;
begin
  xxxDataset.Close;
  query := 'Update xxx set ATCSTATUS = 1 where ATC NOT NULL;';
//  query := 'select * from xxx where ATC NOT NULL;';
  xxxDataset.SQL := query;
  xxxDataset.Open;
end;
initialization
  {$I atc_unit1.lrs}
end.
------------------------------

Met vriendelijke groet,
Paul van der Vlis.

Reply by email

Joost van der Sluis
to Paul van der Vlis

Op maandag 26-05-2008 om 20:01 uur [tijdzone +0200], schreef Paul van der Vlis:

query := 'Update xxx set ATCSTATUS = 1 where ATC NOT NULL;'; // query := 'select * from xxx where ATC NOT NULL;'; xxxDataset.SQL := query; xxxDataset.Open;

You can not open an update-query. Use something like 'xxDataset.ExecSql' instead.

Joost

Reply by email

Paul van der Vlis
to Joost van der Sluis
Joost van der Sluis wrote 9 lines
Op maandag 26-05-2008 om 20:01 uur [tijdzone +0200], schreef Paul van der Vlis: > query := 'Update xxx set ATCSTATUS = 1 where ATC NOT NULL;'; > // query := 'select * from xxx where ATC NOT NULL;'; > xxxDataset.SQL := query; > xxxDataset.Open; You can not open an update-query. Use something like 'xxDataset.ExecSql' instead.

Thanks, it seems to work!

Do you know documentation about sqlite in Lazarus? (Or do I need a Delphi book?)

With regards,
Paul van der Vlis.

Reply by email

Leonardo M. Ramé
to Paul van der Vlis

I wrote a tutorial for FreePascal and FCL-Db using SQLite, you can read it by going to: http://leonardorame.blogspot.com/2007_11_01_archive.html

Leonardo.

Paul van der Vlis escribi?:

Show quoted text 21 lines
Joost van der Sluis schreef: > Op maandag 26-05-2008 om 20:01 uur [tijdzone +0200], schreef Paul van > der Vlis: >> query := 'Update xxx set ATCSTATUS = 1 where ATC NOT NULL;'; >> // query := 'select * from xxx where ATC NOT NULL;'; >> xxxDataset.SQL := query; >> xxxDataset.Open; > You can not open an update-query. Use something like 'xxDataset.ExecSql' > instead. Thanks, it seems to work! Do you know documentation about sqlite in Lazarus? (Or do I need a Delphi book?) With regards, Paul van der Vlis.

Reply by email

Chris37
to Paul van der Vlis: Thanks, it seems to work! Do you know documentation about sqlite in Lazarus? (Or do I…

Paul van der Vlis a ?crit :

Show quoted text 26 lines
Joost van der Sluis schreef: > Op maandag 26-05-2008 om 20:01 uur [tijdzone +0200], schreef Paul van > der Vlis: > >> query := 'Update xxx set ATCSTATUS = 1 where ATC NOT NULL;'; >> // query := 'select * from xxx where ATC NOT NULL;'; >> xxxDataset.SQL := query; >> xxxDataset.Open; >> > You can not open an update-query. Use something like 'xxDataset.ExecSql' > instead. > Thanks, it seems to work! Do you know documentation about sqlite in Lazarus? (Or do I need a Delphi book?) With regards, Paul van der Vlis.

Hi,

You can look here : http://lazarus-fr.net/tiki-index.php?page=Sqlite

Its French Wiki

Chris

Reply by email

Paul van der Vlis
to Leonardo M. Ramé: I wrote a tutorial for FreePascal and FCL-Db using SQLite, you can read it by going to:…

Hello Leonardo, Chris and Luiz,

Thanks for the tutorials. I did already know the site on Geocities, the site of Leonardo was new for me. The French wiki is difficult to read for me, I will try...

But I was looking for a reference. What I found was something in the SVN and a zipfile with the API, what is not really complete.

I think now it will be everything there is, thanks for your help!

With regards,
Paul van der Vlis.

Reply by email

Chris37
to Paul van der Vlis

Paul van der Vlis a ?crit :

Show quoted text 18 lines
Hello Leonardo, Chris and Luiz, Thanks for the tutorials. I did already know the site on Geocities, the site of Leonardo was new for me. The French wiki is difficult to read for me, I will try... But I was looking for a reference. What I found was something in the SVN and a zipfile with the API, what is not really complete. I think now it will be everything there is, thanks for your help! With regards, Paul van der Vlis.

Thank, your welcom :)

Reply by email