Forum Discussion

TAHbKA's avatar
TAHbKA
Occasional Contributor
11 years ago

Qry.First() remains undefined

Am trying to run a code which is pretty much similar to your example here http://support.smartbear.com/viewarticle/30926/ My connection seems to be fine, when am looking in a debugger on the QRY object after QRY.Open() it shows recordcount 2, fieldcount 7, which is correct. I was also able to create a DBTables object, so assume my connection and the query are fine.

However, the QRY.First() remains undefined for some reason. It worked fine in the previous Testcomplete version. This is my code function






QeryTry()


{


 var Qry;


 Qry = ADO.CreateADOQuery();


 Qry.ConnectionString = "Provider=MSDASQL.1;Password=;Persist Security Info=True;User ID=;Data Source="


 Qry.SQL = "select * from "; // Execute the query


 Qry.Open();


 Qry.First();


 var result = (Qry.FieldByName("".Value)); Log.Message("Found " + result);


 return result; 








this is the result Field '' not found Error location: Unit: "" Line: 687 Column: 5. What am I missing? Thanks!

2 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Tanya,


     


    You didn't specify the table name in the query. This might be the cause of this behavior.


     

  • TAHbKA's avatar
    TAHbKA
    Occasional Contributor
    Tanya, I removed here all the data that was specific for my querries. I specified the password, user id, data source and table name. 

    It's really





     var Qry;


    Qry = ADO.CreateADOQuery();


    Qry.ConnectionString = "MSDAORA.1;User ID=<my user id>;Data Source=<my data source>;Password=<my password>;Persist Security Info=False"


       


    Qry.SQL = "select count(*) from <my table name>";


    Qry.Open();


    Qry.First();


    var result = (Qry.FieldByName("count(*)".Value));