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 SubDid some additional research , and I found this article. Very handy and it gave me everything I needed.
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:
- Open the Server Explorer window in Visual Studio.
- Right-click the Data Connections node and select Add Connection.
- 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.
- 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).