tailieunhanh - Hướng dẫn học Microsoft SQL Server 2008 part 92

Khi bạn liên kết với một bảng trong Access SQL Server, Access lưu trữ kết nối thông tin và siêu dữ liệu. Nếu bạn thực hiện thay đổi lược đồ trong SQL Server, các siêu dữ liệu được lưu trữ sẽ là không hợp lệ, và những nỗ lực tiếp theo để mở bảng liên kết sẽ thất bại. Một kỹ thuật phổ biến để tránh số phận này là để xóa tất cả các liên kết khi bạn đóng các ứng dụng truy cập, và bảng relink ngày khởi động | Part V Data Connectivity When you link to a SQL Server table in Access Access caches connection information and metadata. If you make schema changes in SQL Server the cached metadata will be invalid and subsequent attempts to open the linked table will fail. A common technique to avoid this fate is to delete all links when you close the Access application and relink tables on startup. When writing VBA code in Access ADO ActiveX Data Objects is the preferred object model for working with SQL Server. However the DAO Data Access Objects object model is more efficient and full-featured for working with Access objects and tables linked to SQL Server are Access objects. So although you could use ADOX code to create links the code presented in this chapter uses DAO. The DAO object model enables you to manipulate tables using the and objects. The following VBA function takes input parameters for the name of the linked table as it will appear in Access you can specify any legal Access object name here the name of the source table in SQL Server and an ODBC connection string. The code checks to see if the linked table already exists in the local database s TableDefs collection if it does it deletes it and refreshes the collection. The code then creates a new TableDef object using the connection string to connect to SQL Server and specifying the source table. The code appends the new TableDef to the TableDefs collection Public Function LinkTableDAO _ LinkedTableName As String _ SourceTableName As String _ ConnectionString As String As Boolean Links or re-links a single table. Returns True or False based on Err value. Dim db As Dim tdf As On Error Resume Next Set db CurrentDb Check to see if the table link already exists if so delete it Set tdf LinkedTableName If 0 Then LinkedTableName Else Ignore error and reset 0 End If Set tdf .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.