代码之家  ›  专栏  ›  技术社区  ›  notnot

Excel VBA-使用可信连接连接到SQL(无uid/pwd)

  •  10
  • notnot  · 技术社区  · 17 年前

    有没有方法让Excel使用当前用户的网络Windows身份验证(可信连接/集成安全性)连接到SQL Server?我不想依赖SQL登录,也不想在代码中使用uid/密码。

    4 回复  |  直到 10 年前
        1
  •  10
  •   El Ronnoco    15 年前

    我在Excel2003的VBA项目中有这个连接字符串…

    "Provider=SQLOLEDB;Data Source=[You DB Name];Trusted_connection=yes;"
    

    它对我有用!(我正在使用ADODB)

        2
  •  10
  •   Cade Roux    17 年前
    Driver={SQL Native Client};server=servernamehere;database=dbnamehere;Trusted_Connection=yes;
    

    http://www.sqlstrings.com/SQL-Server-connection-strings.htm

    http://www.connectionstrings.com/sql-server

    试试这个:

    Provider=sqloledb;Data Source=myServerName;Initial Catalog=myDatabaseName;Integrated Security=SSPI
    
        3
  •  3
  •   Tomalak    17 年前

    见: http://www.connectionstrings.com/

    特别是 http://www.connectionstrings.com/sql-server-2005 例如:

    Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
    

    或者其他合适的连接字符串。

        4
  •  1
  •   Stefan Michev    13 年前

    vba Excel 2010工作示例

    provider=sqloledb;data source=serveriporname;initial catalog=databasename;trusted_connection=yes;