Results 1 to 2 of 2

Thread: [RESOLVED] [DELPHI] Cannot save to SQLITE database when user types in special characters

  1. #1

    Thread Starter
    Fanatic Member esposito's Avatar
    Join Date
    Sep 2003
    Location
    Perugia, Italy
    Posts
    961

    Resolved [RESOLVED] [DELPHI] Cannot save to SQLITE database when user types in special characters

    When the user types special characters such as quotation marks or commas in an EditBox, the record cannot be saved since those characters interfere with the SQL code.

    Is there any way I can modify the code below so as to prevent the special characters typed by the user from interfering with the Save procedure?



    Code:
    procedure TfrmArchivio.InsertText;
    
    var
      sSQL: String;
    begin
      sl3db.BeginTransaction;
    
      sSQL := 'INSERT INTO lavoratori(ID,varNome,varIndirizzo,varCap,varCitta,varProv,varDataNasc,varLuogoNasc,';
      sSQL := sSQL + 'varContratto,varPrestazione,varAssunzione,varCessazione,varCompenso,varProtocollo,varCodFisc,';
      sSQL := sSQL + 'varIva,varTelCasa,varTelUff,varTelCel,varFax,varEmail,varNote,Ext)';
    
      sSQL := sSQL + ' VALUES (NULL,"' + Trim(txtNome.Text) + '","' + Trim(txtIndirizzo.Text) + '","' + Trim(txtCap.Text) + '","';
      sSQL := sSQL + Trim(txtCitta.Text) + '","' + Trim(txtProv.Text) + '","' + Trim(txtDataNasc.Text) + '","';
      sSQL := sSQL + Trim(txtLuogoNasc.Text) + '","' + Trim(txtContratto.Text) + '","' + Trim(txtPrestazione.Text) + '","';
      sSQL := sSQL + Trim(txtAssunzione.Text) + '","' + Trim(txtCessazione.Text) + '","' + Trim(txtCompenso.Text) + '","';
      sSQL := sSQL + Trim(txtProtocollo.Text) + '","' + Trim(txtCodFisc.Text) + '","' + Trim(txtIva.Text) + '","';
      sSQL := sSQL + Trim(txtTelCasa.Text) + '","' + Trim(txtTelUff.Text) + '","' + Trim(txtTelCel.Text) + '","';
      sSQL := sSQL + Trim(txtFax.Text) + '","' + Trim(txtEmail.Text) + '","' + Trim(txtNote.Text) + '","JPG");';
    
      sl3db.ExecSQL(sSQL);
      sl3db.Commit;
    
    end;
    Thanks in advance.
    Last edited by esposito; May 4th, 2008 at 01:28 AM.
    Since I discovered Delphi and Lazarus, VB has become history to me.

  2. #2

    Thread Starter
    Fanatic Member esposito's Avatar
    Join Date
    Sep 2003
    Location
    Perugia, Italy
    Posts
    961

    Re: [DELPHI] Cannot save to SQLITE database when user types in special characters

    Resolved thanks to another forum.

    Thank you anyway.
    Since I discovered Delphi and Lazarus, VB has become history to me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width