刚刚装了sql2005的开发版,没看见哪有选混合模式的选项.于是选了本地帐户
vs2005里面应该怎么写连接字串啊??

解决方案 »

  1.   

    用连接向导:当你向web窗口加入一个数据访问控件,如gridview的时候,有一个向导启动,根据这个你将生成连接数据库的WEB.config配置,并存贮一个连接名,下次再连接的时候,用这个连接名连接。
      

  2.   

    SQL Server 2005 
     Standard security:"Driver={SQL Native Client};Server=Aron1;Database=pubs;UID=sa;PWD=asdasd;"  Trusted connection:"Driver={SQL Native Client};Server=Aron1;Database=pubs;Trusted_Connection=yes;"  Prompt for username and password:oConn.Properties("Prompt") = adPromptAlways
    oConn.Open "Driver={SQL Native Client};Server=Aron1;DataBase=pubs;"  Enabeling MARS (multiple active result sets):"Driver={SQL Native Client};Server=Aron1;Database=pubs;Trusted_Connection=yes;MARS_Connection=yes"  Encrypt data sent over network:"Driver={SQL Native Client};Server=Aron1;Database=pubs;Trusted_Connection=yes;Encrypt=yes" Download the SQL Native Client here >> (the package contains booth the ODBC driver and the OLE DB provider)
     SQL Native Client OLE DB Provider 
     Standard security:"Provider=SQLNCLI;Server=Aron1;Database=pubs;UID=sa;PWD=asdasd;"  Trusted connection:"Provider=SQLNCLI;Server=Aron1;Database=pubs;Trusted_Connection=yes;"  Prompt for username and password:oConn.Properties("Prompt") = adPromptAlways
    oConn.Open "Provider=SQLNCLI;Server=Aron1;DataBase=pubs;"  Enabeling MARS (multiple active result sets):"Provider=SQLNCLI;Server=Aron1;Database=pubs;Trusted_Connection=yes;MarsConn=yes"  Encrypt data sent over network:"Provider=SQLNCLI;Server=Aron1;Database=pubs;Trusted_Connection=yes;Encrypt=yes" Download the SQL Native Client here >> (the package contains booth the OLE DB provider and the ODBC driver)
     SqlConnection (.NET) 
     Standard Security:"Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;" 
       - or -
    "Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False" 
       (both connection strings produces the same result)
     Trusted Connection:"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;" 
       - or -
    "Server=Aron1;Database=pubs;Trusted_Connection=True;" 
       (both connection strings produces the same result)(use serverName\instanceName as Data Source to use an specifik SQLServer instance)
     Connect via an IP address:"Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;" 
    (DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the Data Source is the port to use (1433 is the default))
     Declare the SqlConnection:C#:
    using System.Data.SqlClient;
    SqlConnection oSQLConn = new SqlConnection();
    oSQLConn.ConnectionString="my connection string";
    oSQLConn.Open(); VB.NET:
    Imports System.Data.SqlClient
    Dim oSQLConn As SqlConnection = New SqlConnection()
    oSQLConn.ConnectionString="my connection string"
    oSQLConn.Open()