Convert variant to string for Query? lazarus / 16-Databases ---------------------------------------------------------------------- jack · 2012-02-04 22:55 Attempting to use the key from a TDBLookupComboBox to update a query string but having trouble. TSQLQuery1.SQL.Text:='SELECT * FROM EMPLOYEE WHERE EMP_PAY_GROUP = '+TDBLookupComboBox1.KeyValue; Throws EVariantError Invalid type cast.  I have tried many things but it is obvious that I do not understand variants. Please straighten me out on this if you will? ---------------------------------------------------------------------- wcleyton · 2012-02-05 00:11 Try this: TSQLQuery1.SQL.Text:='SELECT * FROM EMPLOYEE WHERE EMP_PAY_GROUP = '+IntToStr(TDBLookupComboBox1.KeyValue); ---------------------------------------------------------------------- paweld · 2012-02-08 22:35 or this: Code: [Select]SQLQuery1.Active:=False; SQLQuery1.SQL.Text:='SELECT * FROM EMPLOYEE WHERE EMP_PAY_GROUP = :param0'; SQLQuery1.Params[0].AsInteger:=TDBLookupComboBox1.KeyValue; //or //SQLQuery1.ParamByName('param0').AsInteger:=TDBLookupComboBox1.KeyVal ue; SQLQuery1.Active:=True; Best regards