Excel VBA - connect to sql with a trusted connection (no uid/pwd)

前端 未结 4 698
离开以前
离开以前 2021-02-14 11:37

Is there a way to have Excel connect to Sql Server using the current user\'s network windows authentication (trusted connection/integrated security)? I don\'t want to rely on a

相关标签:
4条回答
  • 2021-02-14 11:49
    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

    Try this one:

    Provider=sqloledb;Data Source=myServerName;Initial Catalog=myDatabaseName;Integrated Security=SSPI
    
    0 讨论(0)
  • 2021-02-14 11:57

    I have this connectionstring in an Excel 2003 VBA project...

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

    And it works for me! (I'm using ADODB)

    0 讨论(0)
  • 2021-02-14 11:57

    See: http://www.connectionstrings.com/

    Especially http://www.connectionstrings.com/sql-server-2005, for example:

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

    or any other suitable connection string you find there.

    0 讨论(0)
  • 2021-02-14 12:03

    Working sample for VBA Excel 2010

    Provider=SQLOLEDB;Data Source=ServerIPOrName;Initial Catalog=DatabaseName;Trusted_connection=yes;

    0 讨论(0)
提交回复
热议问题