I am trying to adopt some Microsoft code to create an odbc connection to an sql server table. This works on my home set up using 'localhost' as the server, but not at work. The server is set up for both types of authentications. My goal is to eliminate setting up odbc manually on all the clients pc's.
Code. '- shows a fake password
Public Function SQLServerLinkedTable()
Dim oCat As ADOX.Catalog
Dim oTable As ADOX.Table
Dim sConnString As String
' Set SQL Server connection string used in linked table.
sConnString = "ODBC;" & _
"Driver={SQL Server};" & _
"Server=(Boxer);" & _
"Database=ReportInventory;" & _
"Uid=rptinvapps;" & _
"Pwd=xxxxx;"
' Create and open an ADOX connection to Access database
Set oCat = New ADOX.Catalog
oCat.ActiveConnection = CurrentProject.Connection
' Create a new Table object
Set oTable = New ADOX.Table
With oTable
.Name = "dbo_tblReportRequestPrelim"
Set .ParentCatalog = oCat
.Properties("Jet OLEDB:Create Link") = True
.Properties("Jet OLEDB:Remote Table Name") = "dbo.tblReportRequestPrelim"
.Properties("Jet OLEDB:Link Provider String") = sConnString
End With
' Add Table object to database
oCat.Tables.Append oTable
oCat.Tables.Refresh
Set oCat = Nothing
End Function
Error.
odbc --connection to server boxer failed.
Note. my work password contains an asterisk. Could this be a problem?
Code. '- shows a fake password
Public Function SQLServerLinkedTable()
Dim oCat As ADOX.Catalog
Dim oTable As ADOX.Table
Dim sConnString As String
' Set SQL Server connection string used in linked table.
sConnString = "ODBC;" & _
"Driver={SQL Server};" & _
"Server=(Boxer);" & _
"Database=ReportInventory;" & _
"Uid=rptinvapps;" & _
"Pwd=xxxxx;"
' Create and open an ADOX connection to Access database
Set oCat = New ADOX.Catalog
oCat.ActiveConnection = CurrentProject.Connection
' Create a new Table object
Set oTable = New ADOX.Table
With oTable
.Name = "dbo_tblReportRequestPrelim"
Set .ParentCatalog = oCat
.Properties("Jet OLEDB:Create Link") = True
.Properties("Jet OLEDB:Remote Table Name") = "dbo.tblReportRequestPrelim"
.Properties("Jet OLEDB:Link Provider String") = sConnString
End With
' Add Table object to database
oCat.Tables.Append oTable
oCat.Tables.Refresh
Set oCat = Nothing
End Function
Error.
odbc --connection to server boxer failed.
Note. my work password contains an asterisk. Could this be a problem?