Recent

Author Topic: TZMSQL insert record  (Read 1803 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 443
TZMSQL insert record
« on: May 16, 2021, 12:23:00 am »
Hi i just started to test tzmsql  i write a file called database.csv it contains 3 fields  nombrecia;direccion;database

i write one record   sarusa;andaros ; test

i con open this file but i can not add new records

      query:='INSERT INTO databases.csv (nombrecia ,direccion , dbasename) VALUES ('''+ENom.Text+''' ,'''+ EDir.Text+''' , '''+ EDb.Text+''');'; 
FormMain.ZMQDSC.SQL.Text:=query;
      FormMain.ZMQDSC.QueryExecute; 

how i can update file



eldonfsr

  • Sr. Member
  • ****
  • Posts: 443
Re: TZMSQL insert record
« Reply #1 on: May 18, 2021, 07:49:38 pm »
Some confuse if use this command don't work
  ZMCC.DatabasePath:=path+'\';
   ZMCC.Connected:=true;

   ZMQDSC.SQL.Text:='INSERT INTO databases.csv ( nombrecia , direccion, dbasename)'+' VALUES( '' SMAC'',''5807'',''smac'''+');';
   showmessage(ZMQDSC.SQL.Text);
   ZMQDSC.QueryExecute;
   ZMQDSC.savetotable;

but i use command like this works
      FormMain.ZMQDSC.Append;
      FormMain.ZMQDSC.FieldByName('NOMBRECIA').AsString:= 'TEST';
      FormMain.ZMQDSC.FieldByName('DIRECCION').AsString:='cONOCIDO 244';
      FormMain.ZMQDSC.Post;
 
      FormMain.ZMQDSC.SaveToTable;

     with las code only i can not delete but update and insert work

some body has experience with this component can help help me please..

thanks
Fernando

eldonfsr

  • Sr. Member
  • ****
  • Posts: 443
Re: TZMSQL insert record
« Reply #2 on: May 19, 2021, 02:20:39 am »
after testing and practicing

what was my error
 the correct command is like this
   ZMQDSEdos.SQL.Text:='CREATE TABLE states (idedo, nombre) ; COMMIT)';
         ZMQDSEdos.QueryExecute;

and now we can insert records
  ZMQDSC.SQL.Text:='INSERT INTO databases ( numero ,nombrecia , direccion, dbasename)'+' VALUES( ''0'','' test1'',''5807'',''testing'''+'); COMMIT';
   ZMQDSC.QueryExecute;

and delete records like this

  FormMain.ZMQDSEdos.SQL.Text:='Delete from states where idedo <> '''+'''; COMMIT';
  FormMain.ZMQDSEdos.QueryExecute;   



first step is connect ZMC connection to folder witch one is going to keep tables like this
   path = path  := GetCurrentDir();
   ZMCC.DatabasePath:=path+'\';
   ZMCC.Connected:=true;

Hope help to some body...




 

TinyPortal © 2005-2018