DSN-less connection using the SQLOLEDB provider : SQLServer « Access « VBA / Excel / Access / Word






DSN-less connection using the SQLOLEDB provider

 
Sub Connect_ToSQLServer2()
   Dim conn As ADODB.Connection

   Set conn = New ADODB.Connection
   With conn
      .Open "Provider=SQLOLEDB;" & _
          "DataSource=mySource;" & _
          "Initial Catalog=myDb;" & _
          "UID=myId; Password=myPassword;"
      .Close
   End With
   Set conn = 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.Creating a SQL Server Connection Object with SQL Server Security
4.Creating a SQL Server Connection Object with Integrated Security
5.Transfer SQLServer database