Forum Discussion

blearyeye's avatar
blearyeye
Contributor
15 years ago

Database connection string

I'm trying to get a database connection to work.



    sproc.ConnectionString =

          "Provider=SQLOLEDB.1;Data Source=(local)\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=True;";

    sproc.CommandText = "Select * from MachineData";

    sproc.CommandType = 1;

    sproc.Execute();



This gives an error for Execute():



    Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done




I'm trying to adapt a connection string that works in C#:

    Data Source=(local)\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=True;



Any suggestions?

6 Replies

  • Well, I wasn't trying to get an OLE DB connection working so much as trying to get anything to work.



    As it turned out (thanks to Nick Olivo of SmartBear support), the easy way to generate a connection string is to use the wizard in the database table checker keyword checkpoint. With that, I was able to generate two strings that worked. The first uses the SQL 10 native client; the second uses an ODBC connection.



          "Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;User ID=\"\";Initial Catalog=MyDb;Data Source=(local)\\SQLEXPRESS;Initial File Name=\"\";Server SPN=\"\""



          "Provider=MSDASQL.1;Persist Security Info=False;Data Source=MyOdbcConnection"



    There really ought to be an article on connection strings that points out this technique. I spent a lot of time trying to get this to work.
  • gid_216's avatar
    gid_216
    Frequent Contributor
    Hi Uj,



    Replace



    DBtab.ConnectionString = "Provider=SQLOLEDB.1;" + _

      "Data Source=23.34.234.34;" + _

      "Initial Catalog= &Chkpnt;"




    To below



      Execute("DBtab.ConnectionString = ""Provider=SQLOLEDB.1; Data Source=23.34.234.34; Initial Catalog= " & Chkpnt & ";""") 








  • Hi Bill,





    Please refer to the following Microsoft knowledge base article to learn what can cause the problem and how you can fix it.





    Also, if you need to pass a backslash to a string variable in JScript, you need to double the backslash character.


  • Hi there,



    I have a small problem regarding the DB Checkpoint connection string (TC 8).



    I want the same DB Checkpoint to work parallely for multiple DB's on multiple VMWare ?



    Below is the code sample i am trying to run for multiple DB's:

    ----------------------------------------------------------------------------------------



    sub ConStringExample(Chkpnt)

     

      ' Specifies a DB Table element

      Set DBTab = DBTables.Check_Info

    '    ' Specifies a connection string

        

      DBtab.ConnectionString = "Provider=SQLOLEDB.1;" + _

      "Data Source=23.34.234.34;" + _

      "Initial Catalog= &Chkpnt;"

     

      DBTab.Check

    End sub

     

     

    sub abc()

    call  ConStringExample(ODB_Test_2013) 

    end sub

    ------------------------------------------------------------------------------------------




    Above I am trying to paramterize the DB name by passing the parameter to the subroutine 'ConStringExample'



    'Check_Info' is my Checkpint name.

    I am not able to run this subroutine. As it fails to accept the variable in 'Initial Catalog' -field of Connectionstring.





    Can anyone guide me on this ... I have tried to parameterize the Checkpoint Value but that also doesnt work.



    The question is Can I Parameterize ConnectionString contents??





    Regards,

    Uj