ODBC Call Failed

jerem

Registered User.
Local time
Today, 23:35
Joined
May 1, 2012
Messages
118
Hi
I have a connection issue. My Ms Access 2010 database is made of linked table to SQL Azure. I have tested the connection string with the following code and it works well:
Code:
Dim qdf As DAO.QueryDef, rst As DAO.Recordset
Dim strResults As String
	Set qdf = CurrentDb.CreateQueryDef("")
	qdf.Connect = DLookup("ConnectionString", "tblConnections", "Active = True")
	qdf.SQL = "SELECT * FROM dbo.tblOutlet"
	qdf.ReturnsRecords = True
	Set rst = qdf.OpenRecordset
	Do Until rst.EOF
		strResults = strResults & rst!ID & vbCrLf
		rst.MoveNext
	Loop
	Debug.Print strResults
	rst.Close
Set rst = Nothing
Set qdf = Nothing
Then I use another code that usually works well on other SQL servers but here I'm getting the error mentioned in the title at td.RefreshLink
Code:
Dim db As Database
Dim td As TableDef
 Dim strConnect As String
	strConnect = DLookup("ConnectionString", "tblConnections", "Active = True")
	Set db = CurrentDb
	For Each td In db.TableDefs
		If InStr(td.Connect, "ODBC") Then
			td.Connect = strConnect
			td.RefreshLink
		End If
	Next

Here is the connection string:
Code:
ODBC;Driver=SQL Server;Server=tcp:/SERVER/,1433;Database=/DATABASE/;Uid=/USER/;Pwd=/PASWWORD/;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;
Can anyone help?
Thank you
 

Users who are viewing this thread

Back
Top Bottom