データベースリンク文字列メソッド
7244 ワード
MSSQL:
アカウントパスワード接続:
Windows認証接続文字列構文:
conn.ConnectionString = @"Data Source=.\servername;database = DBNAME;Integrated security = true";
遅延読書:
あなたはservernameとdbnameを自分のものに変えればいいです.もしこれが覚えにくいと思ったら、Cを使っています.S qlConnectionsStringBuilderで接続列を構築することができます.間違いありません. SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); builder.DataSource = "servername"; builder.InitialCatalog = "DB name"; builder.IntegratedSecurity = true; //sql認証 //builder.UserID = "username"; //builder.Password = "passward"; conn.ConnectionString = builder.ConnectionString;
アカウントパスワード接続:
Windows認証接続文字列構文:
conn.ConnectionString = @"Data Source=.\servername;database = DBNAME;Integrated security = true";
遅延読書:
あなたはservernameとdbnameを自分のものに変えればいいです.もしこれが覚えにくいと思ったら、Cを使っています.S qlConnectionsStringBuilderで接続列を構築することができます.間違いありません. SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); builder.DataSource = "servername"; builder.InitialCatalog = "DB name"; builder.IntegratedSecurity = true; //sql認証 //builder.UserID = "username"; //builder.Password = "passward"; conn.ConnectionString = builder.ConnectionString;
:C# SQL
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
1:Integrated Security
Integrated Security True , UserID, PW , windows 。
False , UserID, PW 。
Integrated Security :sspi , True, True。
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=true;
Data Source=myServerAddress;Initial Catalog=myDataBase;;User ID=myUsername;Password=myPasswordIntegrated Security=false;
2: Trusted_Connection
Trusted_Connection=true, Windows
Trusted_Connection=false; ( Windows ), SQL Server 2000
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=false;
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
3:Initial Catalog
4:WINCE
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;
: SqlConnectionStringBuilder, 。
SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder();
scsb.DataSource = @"(local)\SQLExpress";
scsb.IntegratedSecurity = true;
scsb.InitialCatalog = "Northwind";
SqlConnection myConnection = new SqlConnection(scsb.ConnectionString);
: Setting
1: type (connection string),
2: DataSouce , Server , (local)\SQLExpress
3: , Windows ( Integrated Security=True)
4: ,
Data Source=(local)\SQLExpress;Initial Catalog=Northwind;Integrated Security=True
server = .\sqlexpress;integrated security = true;database = northwind
:SQL2005
sql server 2005 1433 :
->Sql Server Configuration Manager->MSSQLSERVER TCP/IP , , " " , "IP ", "IP1" "IP2" "TCP " 1433," " " "
->Sql Server Configuration Manager->SQL Native Client -> ->TCP/IP TCP/IP " ", " " 1433," " " "。
SQL Server 2005 TCP/IP :
Surface Area Configuration --> Database Engine --> Remote Connections --->Using TCP/IT SQL Server ? ?database englie? ? ( TCP/IP named pipes)
SQL Server Configuration Manager?SQL2005 ? TCP/IP named pipes
: sqlserver2005(Express ), , manage :
manage , sqlserver2005, 。
1. sql2005 , , ->sql server -> -> MSSQLSERVER Database Engine , " ", " TCP/IP named pipes", , .
2. ,Sql server and windows Authentication , : manage ->windows Authentication( windows ),-> -- > >security>Sql server and windows Authentication .
3: Sql server , : manage ->windows Authentication>new query>sp_password null,'sa123456','sa' sa , :sa123456 , , Sql server , sa , :sa123456 .
4: , ,
(server=.\sqlexpress;uid=sa;pwd=sa123456;database=master";
:SQL2000
1: ping IP ping 。
2: Dos telnet IP , 。 telnet 202.114.100.100 1433 1433, 1433 sql server 2000 Tcp/IP 。 , 。 “…… , "。
, 。
1) sql server 2000 。 , 。
2) Tcp/IP , ( ) 。 , -> -> Microsoft SQL Server-> , tcp/ip , , 。
3) tcp/ip 1433 。 tcp/ip , 1433, 。 , , , telnet , 。 , , , , Tcp/ip 2433, 。
4) sp2 , windows , 1433 , windows ( )。
5) 1433 。 tcp 1433 , 。 dos netstat -a -n netstat -an, tcp 127.0.0.1 1433 listening 。 , sql server 2000 sp3 。 , select @@version , 8.0.2039 。 , telnet ip 1433 , 。 , 。
3: -> Microsoft SQL Server -> 。 , tcp/ip , 1433( , )。
4: -> SQlserver -> sqlserver -> -> IP-> -> Sqlserver -> -> (sa,password)-> -> -> -> -> -> IP-> (sa,password)-> , , SQL Server 4 , 15 。 : -> -> -> "SQL Server " , " " -> -> ( ) -> -> -> -> ( ) , , 。
5: SQL Server " Windows" , SQL Server ( sa ) 。 :
1) , " Windows " SQL Server。
2) "SQL Server ", SQL Server , " ", " " 。
3) " " , "SQL Server Windows "。
4) SQL Server 。( dos net stop mssqlserver ,net start mssqlserver , )。
CSDN , :http://blog.csdn.net/fredrickhu/archive/2009/12/08/4961799.aspx