Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
8 years ago
Solved

How to get to know the "Connection String" needed to work with ADO.

As described here,

 

one approach to do validation on Databases, is to make use of  ADO CreateCommand Method.

 

To be able to make this work, you will need to define the "Connection string" .

 

Where can I find the information, to be used to populate the value Conn.ConnectionString ?

 

I am using MS SQL Server Management Studio 2016 to connect to the DB, but I cant find this Connectionstring info on all settings/properties, screens.

 

Is there anyone who knows how to get this info?

 

 

 

Sub TestADO
  Dim Conn, Rs

  Log.AppendFolder "Authors Table"

  ' Creates and opens a connection
  Set Conn = CreateObject("ADODB.Connection")
  Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
                          "Data Source=C:\Program Files\Microsoft Visual Studio\VB98\biblio.mdb"
  Conn.Open

  ' Creates and opens a recordset
  Set Rs = CreateObject("ADODB.Recordset")
  Rs.Open "Authors", Conn, 3, 1, 2 ' adOpenStatic, adLockReadOnly, adCmdTable

  ' Processes data
  Rs.MoveFirst
  While Not Rs.EOF
    Log.Message Rs.Fields.Item("Author").Value
    Rs.MoveNext
  WEnd

  ' Closes the recordset and connection
  Rs.Close
  Conn.Close

  Set Rs = Nothing
  Set Conn = Nothing
End Sub
  • Did some additional research , and I found this article. Very handy and it gave me everything I needed.

     

     

  • mgroen2's avatar
    mgroen2
    8 years ago

    SmartBear support desk helped me out with it as well, with these steps on how to get the Connection String from MS Visual Studio:

     

    You can try connecting to your database from Visual Studio:

    1. Open the Server Explorer window in Visual Studio.
    2. Right-click the Data Connections node and select Add Connection.
    3. Select Microsoft SQL Server as Data Source and .NET Framework Data Provider for OLE DB as Data provider. You'll then need to establish a connection  - select the server, provide valid credentials and select your database.
    4. When the connection is established, you can select you database on the list and see the Connection String value in the Properties tab (see the attached screenshot).

     

     

4 Replies

    • mgroen2's avatar
      mgroen2
      Super Contributor

      SmartBear support desk helped me out with it as well, with these steps on how to get the Connection String from MS Visual Studio:

       

      You can try connecting to your database from Visual Studio:

      1. Open the Server Explorer window in Visual Studio.
      2. Right-click the Data Connections node and select Add Connection.
      3. Select Microsoft SQL Server as Data Source and .NET Framework Data Provider for OLE DB as Data provider. You'll then need to establish a connection  - select the server, provide valid credentials and select your database.
      4. When the connection is established, you can select you database on the list and see the Connection String value in the Properties tab (see the attached screenshot).

       

       

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        Think I used a combination of the TestComplete documentation. A quick google for "sql connection string" (or something like that) and then a quick chat with the devs to find out the right values to use for our particular DB.

  • mgroen2's avatar
    mgroen2
    Super Contributor

    Did some additional research , and I found this article. Very handy and it gave me everything I needed.