Einzelnen Beitrag anzeigen

Benutzerbild von sx2008
sx2008

Registriert seit: 16. Feb 2008
Ort: Baden-Württemberg
2.332 Beiträge
 
Delphi 2007 Professional
 
#2

AW: Mysql Typs (Null) Typ (Integer)

  Alt 25. Aug 2013, 21:43
Delphi-Quellcode:
// Fill a parameter with NULL
QueryB.ParamByName('NewID').Value := Null;

// Fill a field with NULL
QueryB['SomeField'] := Null;
// alternative way to set a field to NULL
QueryB.FieldByName('SomeField').Clear;

// testing if a field is NULL
if Query.FieldByName('SomeField').IsNull then ...



// Copy a Field that might be NULL
// the VCL converts different datatypes on the fly e.g. from Integer -> string
QueryB['DestinationField'] := QueryA['SourceField'];
// this is the same as (long version of the line above)
QueryB.FieldByName('DestinationField').Value := QueryA.FieldByName('SourceField').Value;



// and some bonus info...
// how to set the SQL string of a query in a single line without using .Clear() followed by a .Add()
Query.SQL.Text := 'SELECT * FROM TableA WHERE ID = :ID';
fork me on Github
  Mit Zitat antworten Zitat