Forum Discussion

asifmpatel's avatar
asifmpatel
Occasional Contributor
10 years ago

VB Script RunTime error when attempting to create a new ADO Query in VB Script

Hi there

When attempting to execute my KeywordTest - we are being displayed with the attached VB Script Run-Time errors.

At the start of my KeywordTest a new connection to the database is made to populate a database variable.

 

At the end of my test when im attempting to carry out a DBCheck - im trying to connect to the database using ADO. The script is failing because it thinks there is already an open connection.

 

Any ideas how i can get round this problem?

 

Thanks

AP

 

 

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    The error message actually seems to indicate that it's trying to create a new MDF file rather than simply open a query.  Could you copy and paste the ADO code for the Qry that you are creating? I'm curious as to what you have written and as to whether there is something misconfigured there.

  • asifmpatel's avatar
    asifmpatel
    Occasional Contributor

    Hi Robert 

    here is the code:

     

    Dim TRef
    TRef = KeywordTests.PCN_On_Hold_Compensate_Status_600_.Variables.t_reference("Col_0")
    KeywordTests.PCN_On_Hold_Compensate_Status_600_.Variables.t_reference.Disconnect
    'Set KeywordTests.PCN_On_Hold_Compensate_Status_600_.Variables.t_reference = nothing
    Qry.ConnectionString = "Provider=SQLNCLI11.1;Persist Security Info=False;User ID=icpsadmin; Password=3708738;Initial Catalog=Test;Data Source=10.10.15.56;Initial File Name="";Server SPN="";"
    ' Specify the SQL expression
    Qry.SQL = "Select t_on_hold FROM tickets where t_reference = :Param_Ref"
    ' Specify the parameter value
    Qry.Parameters.ParamByName("Param_Ref").Value = TRef
    ' Execute the query
    Qry.Open
    ' Process results and insert data into the test log
    Qry.First
    While Not Qry.EOF
    Log.Message Qry.FieldByName("t_on_hold").Value
    Qry.Next
    Wend
    ' Closes the query
    Qry.Close

     

     

    Thanks

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Where is Qry defined? I see it being called, but not where it is defined. It just seems like there is a variable, Qry, that is being defined for creating a database (the MDF) and writing to it that is being reused. 

       

      Just a question... is there a reason why you are using this ADO code to verify the results of your database and that you're not using a Database Checkpoint?