zoukankan      html  css  js  c++  java
  • SQL Server 连接

    ODBC
    Standard Security
    Driver={SQL Server};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

    Trusted connection
    Driver={SQL Server};Server=myServerAddress;Database=myDataBase;Trusted_Connection=Yes;
        Prompt for username and password  
        This one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.
    oConn.Properties("Prompt") = adPromptAlways

    Driver={SQL Server};Server=myServerAddress;Database=myDataBase;

    OLEDB, OleDbConnection (.NET)
    Standard Security
    Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

    Trusted connection
    Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;


        Use serverName\instanceName as Data Source to use a specific SQL Server instance. Please note that the multiple SQL Server instances feature is available only from SQL Server version 2000 and not in any previous versions.


        Prompt for username and password
         This one is a bit tricky. First set the connection object's Provider property to "sqloledb". Thereafter set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.
    oConn.Provider = "sqloledb"
    oConn.Properties("Prompt") = adPromptAlways

    Data Source=myServerAddress;Initial Catalog=myDataBase;

    Connect via an IP address
    Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
        DBMSSOCN=TCP/IP. This is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.
    SqlConnection (.NET)
    Standard Security
    Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

        Standard Security alternative syntax
        This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.
    Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;

    Trusted Connection
    Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
        Trusted Connection alternative syntax
        This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.
     
    Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
        Use serverName\instanceName as Data Source to use a specific SQL Server instance. Please note that the multiple SQL Server instances feature is available only from SQL Server version 2000 and not in any previous versions.
        Trusted Connection from a CE device
        Often a Windows CE device is not authenticated and logged in to a domain. To use SSPI or trusted connection / authentication from a CE device, use this connection string
     
    Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;
    Note that this will only work on a CE device.

      Connect via an IP address
    Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
    DBMSSOCN=TCP/IP. This is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.
    Specifying packet size
    Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;Packet Size=4096;

      Data Shape MS Data Shape
    Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=myServerAddress;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;

    说明:此文章来源于:http://www.connectionstrings.com/
  • 相关阅读:
    获取当前div中的所有div的个数和每一个div的ID and 根据屏幕分辨率计算高度
    在当前页获取父窗口中母版页中的服务器控件的ID
    Asp.net C# 获取本周上周本月上月本年上年第一天最后一天时间大全
    C#后台调用前台js方法
    IComparable与排序
    C# 与.NET2.0 中类型Type的GetMethod方法
    下拉菜单及时间段的获取
    黑马程序员——JAVA基础之简述集合collection
    黑马程序员——JAVA基础之基本数据类型包装类和1.5JDK新特性装箱
    黑马程序员——JAVA基础之String和StringBuffer
  • 原文地址:https://www.cnblogs.com/abcdwxc/p/960523.html
Copyright © 2011-2022 走看看