troubleshooting Question

Could not convert a variant of type (Null) into type (string) - Error when running a query

Avatar of saroren
saroren asked on
Delphi
2 Comments1 Solution2025 ViewsLast Modified:
Hi,

I have a Grid with Data's. If i double click on the recod it has to some more details.

The below works only if the first set of query has some records. But if the first doesnt return any record then i get a error message "Could not convert a variant of type (Null) into type (string)'
ie if
 wo_detail.FormWODetail.grid1063Details.DataSource.DataSet.FieldValues['workorder']);  
returns no record.

i would like to change the below such that i want to run the second and third query only if the first query returns any record.



    wo_detail.FormWODetail.qry1063Details.Close;
    wo_detail.FormWODetail.qry1063Details.Parameters.ParamValues['base'] := LeftStr(string(cop_grdMain.DataSource.DataSet.FieldValues['workorder']), 6);
    wo_detail.FormWODetail.qry1063Details.Parameters.ParamValues['workorder'] := string(cop_grdMain.DataSource.DataSet.FieldValues['workorder']);
    wo_detail.FormWODetail.qry1063Details.Open;

    wo_detail.FormWODetail.qry1063Details1.Close;
    wo_detail.FormWODetail.qry1063Details1.Parameters.ParamValues['workorder'] := string(wo_detail.FormWODetail.grid1063Details.DataSource.DataSet.FieldValues['workorder']);
    wo_detail.FormWODetail.qry1063Details1.Open;

    wo_detail.FormWODetail.qry1063Details2.Close;
    wo_detail.FormWODetail.qry1063Details2.Parameters.ParamValues['part'] := string(wo_detail.FormWODetail.grid1063Details1.DataSource.DataSet.FieldValues['wod_part']);
    wo_detail.FormWODetail.qry1063Details2.Open;

    FormWODetail.show();

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros