国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

如何在 Access 2003 和 Access 2002 中創建 DSN 的連接到 SQLServer 對鏈接

2024-05-04 11:02:42
字體:
來源:轉載
供稿:網友
方法 1: 使用 CreateTableDef 方法
CreateTableDef 方法可創建鏈接表。 若要使用此方法, 創建一個新模塊, 然后以下 AttachDSNLessTable 函數添加到新模塊。
復制代碼 代碼如下:
'//Name     :   AttachDSNLessTable
'//Purpose  :   Create a linked table to SQL Server without using a DSN
'//Parameters
'//     stLocalTableName: Name of the table that you are creating in the current database
'//     stRemoteTableName: Name of the table that you are linking to on the SQL Server database
'//     stServer: Name of the SQL Server that you are linking to
'//     stDatabase: Name of the SQL Server database that you are linking to
'//     stUsername: Name of the SQL Server user who can connect to SQL Server, leave blank to use a Trusted Connection
'//     stPassword: SQL Server user password
Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
    On Error GoTo AttachDSNLessTable_Err
    Dim td As TableDef
    Dim stConnect As String

    For Each td In CurrentDb.TableDefs
        If td.Name = stLocalTableName Then
            CurrentDb.TableDefs.Delete stLocalTableName
        End If
    Next

    If Len(stUsername) = 0 Then
        '//Use trusted authentication if stUsername is not supplied.
        stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
    Else
        '//WARNING: This will save the username and the password with the linked table information.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 和林格尔县| 枣强县| 遂昌县| 当阳市| 阿图什市| 清丰县| 高陵县| 安国市| 四川省| 高要市| 海淀区| 遵义市| 海原县| 安图县| 陆川县| 土默特左旗| 金川县| 固安县| 山西省| 襄城县| 漾濞| 女性| 松桃| 高要市| 正定县| 阿拉尔市| 水富县| 长宁区| 咸宁市| 静海县| 靖安县| 论坛| 泌阳县| 城步| 临安市| 灌阳县| 旬阳县| 大厂| 平昌县| 亳州市| 民丰县|