国产探花免费观看_亚洲丰满少妇自慰呻吟_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.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 枣强县| 金塔县| 庄浪县| 巴彦县| 宜章县| 桑植县| 丰县| 舒城县| 尼玛县| 阿拉尔市| 吉水县| 苍梧县| 湖南省| 柳江县| 石门县| 依安县| 昭通市| 靖西县| 新乡市| 北辰区| 府谷县| 嘉善县| 仲巴县| 射洪县| 定兴县| 芜湖县| 莒南县| 湘潭市| 唐河县| 宜黄县| 安吉县| 恭城| 潞西市| 于都县| 响水县| 久治县| 宁波市| 庆元县| 黎城县| 浦城县| 信丰县|