Connecting to an SQL Server Using a DSN-less Connection : SQLServer « Access « VBA / Excel / Access / Word






Connecting to an SQL Server Using a DSN-less Connection

 
Sub Connect_ToSQLServer()
   Dim conn As ADODB.Connection

   Set conn = New ADODB.Connection
   With conn
      ' DSN-less connection using the ODBC driver
      ' (modify the data source information below)
      .Open "Driver={SQL Server};" & _
          "Server=192.168.1.100;" & _
          "UID=myId;" & _
          "PWD=myPassword;" & _
          "Database=SupportDb"
      .Close
   End With
   Set conn = Nothing
End Sub

 








Related examples in the same category

1.Connecting to an SQL Server Database
2.DSN-less connection using the SQLOLEDB provider
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