Home > Back-end >  Invalid variant operation error
Invalid variant operation error

Time:10-22

Invalid variant operation

ADOQuery1 - & gt; The Open ();
AnsiString CFH;
CFH=ADOQuery1 - & gt; FieldValues [" ssno "] + DateToStr (Date ()) + Edit2 - & gt; The Text;
An1="select * from cure the where";
An1 +="psno='" + Edit1 - & gt; The Text + "' and cfsno='" + CFH +"' ";
ADOQuery1 - & gt; SQL - & gt; The Clear ();
ADOQuery1 - & gt; SQL - & gt; Add (an1);
Please give advice or comments

CodePudding user response:

ADOQuery1 - & gt; FieldValues [" ssno "]
Change To the
ADOQuery1 - & gt; AsString FieldByName (" ssno ")

CodePudding user response:

ADOQuery1 - & gt; FieldValues [" ssno "] was a Variant, if it is NULL, cannot be converted to the String, throws the Variant convert exceptions,
AsString method is used, however, is a string, then is unable to distinguish field is an empty string or NULL, NULL and empty string, the image of some database is no difference, some have distinction,

  • Related