Re: Refreshing sql links to sql server need reboot to work
- From: Bruce <deluxeinformation@xxxxxxxxx>
- Date: Tue, 29 Jul 2008 15:30:45 -0700 (PDT)
On Jul 29, 12:18 am, SmartbizAustralia <t...@xxxxxxxxxxxxxxx> wrote:
Weird issue.
Need to change the connection (dsn less connection of course) to sql
server from access 2007 because they blew away the security model!
But the database requires a reboot before it takes effect!
Anyone else have this issue and/or know the fix?
I assume you mean relink tables when you say 'change the connection'?
If so...I use DAO to do this and it seems to work fine for me. Here
is the code I use. There are a couple of external calls to functions
that check to see if a tabledef already exists and whether a connect
string utilizes a trusted connection or not, but the general idea of
the code should be clear. I seem to recall it being necessary to
completely delete the original tabledef for each linked table and also
to refresh the tabledefs collection in order for the process to work
properly.
Sub RelinkTable_SQL(strTbl As String, _
strConnect As String)
' strTbl - Name of table to be (re)connected
' strConnect - database connect string
Dim tdf As DAO.TableDef
Dim lngAttribute As Long
Dim db As DAO.Database
On Error GoTo RelinkTable_SQL_Error
Set db = CurrentDb
If TableDefExists(strTbl) Then
db.TableDefs.Delete strTbl
db.TableDefs.Refresh
End If
If SQL_ConnectString_TrustedConnection_get(strConnect) Then
' TRUSTED CONNECTION
Set tdf = db.CreateTableDef(strTbl)
Else
' SAVED UID AND PASSWORD
Set tdf = db.CreateTableDef(strTbl, dbAttachSavePWD)
End If
tdf.Connect = strConnect
tdf.SourceTableName = strTbl
db.TableDefs.Append tdf
db.TableDefs.Refresh
On Error GoTo 0
Exit Sub
RelinkTable_SQL_Error:
Dim uError As New clsError
Select Case Err.Number
Case Else
uError.Handle Err, "Form_frmUpdateLinkedTables_Relink",
"RelinkTable_SQL"
End Select
End Sub
HTH,
Bruce
.
- References:
- Refreshing sql links to sql server need reboot to work
- From: SmartbizAustralia
- Refreshing sql links to sql server need reboot to work
- Prev by Date: Re: Calculate Median with Conditions
- Next by Date: Re: Calculate Median with Conditions
- Previous by thread: Refreshing sql links to sql server need reboot to work
- Next by thread: Database properties
- Index(es):
Relevant Pages
|