Log in

View Full Version : ADO to Link SQL Server Table



jo15765
04-07-2015, 07:35 PM
What would ADO code be to link a SQL server table into my access database?

jo15765
04-09-2015, 07:34 PM
*BUMP* --- anyone know if/how this is achievable?

jonh
04-10-2015, 01:20 AM
http://www.access-programmers.co.uk/forums/showthread.php?t=156294

If you just want to read data


Private Sub Command0_Click()
Const MYDB = "MY_SQL_DATABASE"
Const MYTBL = "MY_SQL_TABLE"

Dim conn As New ADODB.Connection
conn.Open "DSN=" & MYDB & ";database=" & MYDB & ";Trusted_Connection=Yes;"

With New ADODB.Recordset
Set .ActiveConnection = conn
.Source = "SELECT * FROM " & MYTBL
.Open
Debug.Print .RecordCount
.Close
End With
conn.Close
End Sub