Einzelnen Beitrag anzeigen

Blamaster

Registriert seit: 20. Jul 2007
230 Beiträge
 
#1

Zeos Sqlite probleme beim erstellen von Einträgen

  Alt 15. Mai 2011, 15:33
Datenbank: Sqlite • Version: 3 • Zugriff über: D7
Hi,

ich versuche gerade mich ein wenig in Datenbanken einzuarbeiten.

Ich habe folgenden Code erstellt:

Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
  with ZCon do
  begin
    Protocol := 'sqlite-3';
    Database := 'bla.sql';
    Connect;
  end;
  Zqry.Connection := ZCon;

  try
    Zqry.SQL.Text := 'CREATE TABLE IF NOT EXISTS `product` (' +
      '`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,' +
      '`producer` TEXT NOT NULL,' +
      '`name` TEXT NOT NULL,' +
      '`category` TEXT NOT NULL,' +
      '`wohnort` TEXT NOT NULL,' +
      '`size` INTEGER NOT NULL' + ');';
    Zqry.ExecSql;
  finally
    ZCon.Connected := false;
  end;

end;

procedure TForm1.btn1Click(Sender: TObject);
begin
  try
    ZCon.Connected := true;

    Zqry.SQL.Text := 'INSERT INTO `product` ' +
      '(`id`, `producer`, `name`, `category`, `wohnort`, `size`)' +
      ' VALUES ' +
      '('''', ''' + 'bla' + ''', ''' + 'blub' +
      ''', ''' + 'lol' + ''', ''' + 'ort' +
      ''', ''' + '31139' + ''');';

    Zqry.ExecSql; //SQL-Statement ausführen
  finally
    ZCon.Connected := False; //Verbindung trennen
  end;
end;
Leider kommt es beim btn1Click zu folgendem Fehler:

---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EZSQLException with message 'SQL Error: datatype mismatch'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------

Welcher Datentyp passt denn dort nicht ?

Gruß Yannic
  Mit Zitat antworten Zitat