Creating a SQL Server Connection Object with SQL Server Security : SQLServer « Access « VBA / Excel / Access / Word






Creating a SQL Server Connection Object with SQL Server Security

 
Sub CreateConnection()
    'Declare and instantiate the connection
    Dim cnn As ADODB.Connection
    Set cnn = New ADODB.Connection

    'Open the connection
    cnn.Open "Provider=SQLOLEDB.1;" & _
            "Data Source=(local); Initial Catalog=NorthWind;" & _
            "User ID=sa;PWD="

    'Close the connection
    cnn.Close
    'Destroy the connection object
    Set cnn = Nothing
End Sub

 








Related examples in the same category

1.Connecting to an SQL Server Database
2.Connecting to an SQL Server Using a DSN-less Connection
3.DSN-less connection using the SQLOLEDB provider
4.Creating a SQL Server Connection Object with Integrated Security
5.Transfer SQLServer database