I have uploaded my back end database to an Access App on Sharepoint 365. I have set the permissions to allow access from any location and to allow read-write. When I create a ODBC data source in the ODBC Data Source Administrator, the connection works fine.
My front end includes code to make a DSN-less connection to the tables. That code was working fine when the back end was on a "normal" SQL Server. Now, on Sharepoint, it fails with error 3151.
Here is the code I'm using:
the error occurs at the line:
CurrentDb.TableDefs.Append td
I've been trying to correct this for 2 solid days without success. I've tried several different styles of connection strings (all using the exact credentials that worked in the ODBC Administator). I'm at my wit's end.
Does anyone see an error in my code?
Has anyone had success making a DSN-less connection to SQL Azure on Sharepoint 365?
Thanks,
Sup
My front end includes code to make a DSN-less connection to the tables. That code was working fine when the back end was on a "normal" SQL Server. Now, on Sharepoint, it fails with error 3151.
Here is the code I'm using:
Code:
Private Sub cmdConnect_Click()
Dim rst As DAO.Recordset
Dim strTblName As String
Dim strLocTblName As String
Dim strRemTblName As String
Dim strServer As String
Dim strDatabase As String
Dim strUser As String
Dim strPWD As String
Dim stConnect As String
Dim td As TableDef
On Error GoTo cmdConnect_Click_Error
strServer = Me.txtServer '= xxxxxxxxxx.database.windows.net
strDatabase = Me.txtDB '= xx_xxxxxxxx_xxxx_xxxx_xxxx_xxxxxxxxxxxx
strUser = Me.txtUID '= xx_xxxxxxxx_xxxx_xxxx_xxxx_xxxxxxxxxxxx_ExternalWriter
strPWD = Me.txtPwd '= xxxxxxxxxxxxxxx
Set rst = CurrentDb.OpenRecordset("tblLinkTables")
If rst.RecordCount > 0 Then
rst.MoveLast
rst.MoveFirst
Do While Not rst.EOF
strLocTblName = rst![TableName]
strRemTblName = "Access." & strTblName
For Each td In CurrentDb.TableDefs
If td.Name = strLocTblName Then
CurrentDb.TableDefs.Delete strLocTblName
End If
Next
stConnect = "ODBC;DRIVER=SQL Server Native Client 11.0;SERVER=tcp:" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword & ";Encrypt=yes;"
Set td = CurrentDb.CreateTableDef(strLocTblName, dbAttachSavePWD, strRemTblName, stConnect)
CurrentDb.TableDefs.Append td
rst.MoveNext
Loop
End If
On Error GoTo 0
Exit Sub
cmdConnect_Click_Error:
MsgBox "Error " & err.Number & " (" & err.Description & ") in procedure cmdConnect_Click of VBA Document Form_AfrmTestCode"
End Sub
the error occurs at the line:
CurrentDb.TableDefs.Append td
I've been trying to correct this for 2 solid days without success. I've tried several different styles of connection strings (all using the exact credentials that worked in the ODBC Administator). I'm at my wit's end.
Does anyone see an error in my code?
Has anyone had success making a DSN-less connection to SQL Azure on Sharepoint 365?
Thanks,
Sup