Ver Mensaje Individual
  #5  
Antiguo 12-10-2006
fly fly is offline
Miembro
 
Registrado: abr 2005
Posts: 65
Reputación: 20
fly Va por buen camino
Prueba a filtrar la cadena añadiendo otras comillas (simples) , yo acabo de pasar una DB de Dialesct 1 al 3 y esta funcion me sigue valiendo (aunque antes usaba 2 comillas dobles "" en vez de dos simples ''

Código Delphi [-]
Function TDMF1.TextoSQL(txt : string):string; // Pone comillas al inicio y final del texto
   var c : integer;                       // tambien cambia las comillas por unas dobles
       txt2: string;
  begin

  txt2:='''';
    for c:=1 to Length(txt) do
       if txt[c]<>''''
          then txt2:=txt2+txt[c]
          else txt2:=txt2+''''''; // convertimos las comillas en doble_comillas

    txt2:=txt2+'''';
    TextoSQL:=txt2;
  end;

Su uso es tan simple como la propia función (yo uso unas TIBQuery de lo mas normalito) :

Código Delphi [-]
  Dmf1.edit_q.SQL.Text:=
        ' INSERT INTO Articulos (ref, nombre) '+
        ' VALUES ('+
         Dmf1.TextoSQL(edit_ref.Text)+', '+
         Dmf1.TextoSQL(edit_nom.Text)+
        ')';

  dmf1.edit_q.Close;
  dmf1.edit_q.Prepare;
  dmf1.edit_q.ExecSQL;

A ver si esto te vale, Suerte.

Última edición por fly fecha: 12-10-2006 a las 05:24:43.
Responder Con Cita