Recent

Author Topic: problem with TSQLQuery  (Read 3412 times)

tiberi72

  • New Member
  • *
  • Posts: 24
    • Personal Homepage
problem with TSQLQuery
« on: February 16, 2011, 04:25:19 pm »
Hello,
can anyone help me?

I write this code:
  MyDb2:= TIBConnection.Create(Nil);
  MyTrans2 := TSQLTransaction.Create(Nil);
  MySql2:= TSQLQuery.Create(Nil);
  Mydb2.Databasename := 'C:\Archivio.fdb';
  Mydb2.UserName := 'SYSDBA';
  MyDb2.PassWord := 'masterkey';
  MyDb2.Transaction := MyTrans2;
  MyDb2.Connected := True;
  MyTrans2.DataBase := MyDb2;
  MyTrans2.active := true;
  MyTrans2.action := caCommit;
  MySql2.Database :=Mydb2;
  MySql2.Transaction := MyTrans2;
  Mysql2.ReadOnly := false;             

          S :='INSERT INTO MITTENTI ( CODICE, RAGSOC, INDIRIZZO, CITTA, CAP, ';
          S := S + 'PROVINCIA, NAZIONE, PI, CODICECOMMITTENTE, AGGIORNATO, OP1, ';
          S := S + 'OP2, ALIAS, DISABILITATO, UTENTEINTERNET, FLAGARCHIVIAZIONE) ';
          S := S + 'VALUES( ''';
          S := S + MySql1.FieldByName('ANATIP').AsString ;
....
....
          S := S + ''')';             
          Mysql2.sql.text:= S;   
          Mysql2.Execsql;   

But  after this I can't find the new record in the table. Why?

JimBeam

  • New Member
  • *
  • Posts: 36
Re: problem with TSQLQuery
« Reply #1 on: February 16, 2011, 05:55:45 pm »
Wild guess: you might need to explicitly commit the transaction e.g. with MyTrans2.action.commit.

Note: I haven't looked at what your code MyTrans2.action := caCommit does, so sorry if the guess is wrong...

 

TinyPortal © 2005-2018