Q: When using an MDB to link with SQL Server 2000, sometimes you need to refresh the linked table, how to do it simply and easily?
A: The following code can achieve the purpose (the resolution of this topic refers to the user Cwang code, and the Microsoft engineer Billy Yao enthusiastic help):
Function relink ()
Dim DB as Database
Dim TBL as TableDef
Dim A as String
Dim B as String
Dim D as String
A = "sa" database user
b = "ABC" Database password
D = "ABCDE" database name
Set db = CurrentDb
For each tbl in db. TableDefs
If tbl. Attributes = 536870912 Then
Tbl. Connect = "FILEDSN=D:\DEMO\STEEL.DSN; Uid= "& A &"; Pwd= "& B &"; wsid=;D atabase= "& D &"; NETWORK=DBMSSOCN "'
Tbl. Attributes = dbAttachSavePWD
Tbl. RefreshLink
End If
Next
End Function
Enclosed is the answer to the Microsoft engineer Billy Yao:
According to your description, my answer to your question is as follows:
1. dsn=gnts gnts is the file name of the system DSN.
2. UID is the username, and its value is determined by the value of variable A. PWD is a password, and its value is determined by the value of the variable B.
3. Wsid refers to the workstation's ID number (Workstation ID). The value of the variable d represents the name of the database. NETWORK=DBMSSOCN refers to the network library (network library) used by TCP/IP.