VB.NET สอนเขียน Connection strings ของ SQL 2008 ]

ผู้เขียน หัวข้อ: VB.NET สอนเขียน Connection strings ของ SQL 2008  (อ่าน 547 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

DEKTAI2U.COM

  • Administrator
  • เด็กมัธยม
  • *****
  • ออฟไลน์
    Level and Hp Level 17 : Exp 8%
    HP: 1%


    • ดูรายละเอียด
VB.NET สอนเขียน Connection strings ของ SQL 2008
« เมื่อ: วันที่ 13 มีนาคม 2014 เวลา 15:52:42 น. »
Connection strings for SQL Server 2008

Connection strings คือ คำสั่งที่ใช้สำหรับเชื่อมต่อฐานข้อมูล ซึ่งใช้งานร่วมกับ คำสั่งเชื่อมต่อ

อ้างถึง
.NET Framework Data Provider for SQL Server
Type .NET Framework Class Library
Usage System.Data.SqlClient.SqlConnection
Manufacturer Microsoft

Standard Security
โค๊ด: [Select]
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Standard Security alternative syntax
โค๊ด: [Select]
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
Trusted Connection
โค๊ด: [Select]
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
Trusted Connection alternative syntax
โค๊ด: [Select]
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Connecting to an SQL Server instance
โค๊ด: [Select]
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;
Trusted Connection from a CE device
โค๊ด: [Select]
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;
Connect via an IP address
โค๊ด: [Select]
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Enabling MARS (multiple active result sets)
โค๊ด: [Select]
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True; MultipleActiveResultSets=true;
Attach a database file on connect to a local SQL Server Express instance
โค๊ด: [Select]
Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes
Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
โค๊ด: [Select]
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
Using an User Instance on a local SQL Server Express instance
โค๊ด: [Select]
Data Source=.\SQLExpress;Integrated Security=true; AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;
Database mirroring
โค๊ด: [Select]
Data Source=myServerAddress;Failover Partner=myMirrorServerAddress;Initial Catalog=myDataBase;Integrated Security=True;
Asynchronous processing
โค๊ด: [Select]
Server=myServerAddress;Database=myDataBase;Integrated Security=True;Asynchronous Processing=True;


อ้างถึง
SQL Server Native Client 10.0 OLE DB Provider
Type OLE DB Provider
Usage Provider=SQLNCLI10
Manufacturer Microsoft

Standard security
โค๊ด: [Select]
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;
Trusted connection
โค๊ด: [Select]
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;
Connecting to an SQL Server instance
โค๊ด: [Select]
Provider=SQLNCLI10;Server=myServerName\theInstanceName;Database=myDataBase; Trusted_Connection=yes;
Prompt for username and password
โค๊ด: [Select]
oConn.Properties("Prompt") = adPromptAlways

oConn.Open "Provider=SQLNCLI10;Server=myServerAddress;DataBase=myDataBase;

Enabling MARS (multiple active result sets)
โค๊ด: [Select]
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;MARS Connection=True;
Encrypt data sent over network
โค๊ด: [Select]
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;Encrypt=yes;
Attach a database file on connect to a local SQL Server Express instance
โค๊ด: [Select]
Provider=SQLNCLI10;Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname; Trusted_Connection=Yes;
Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
โค๊ด: [Select]
Provider=SQLNCLI10;Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
Database mirroring
โค๊ด: [Select]
Provider=SQLNCLI10;Data Source=myServerAddress;Failover Partner=myMirrorServerAddress;Initial Catalog=myDataBase;Integrated Security=True;


อ้างถึง
.NET Framework Data Provider for OLE DB
Type .NET Framework Wrapper Class Library
Usage System.Data.OleDb.OleDbConnection
Manufacturer Microsoft

Bridging to SQL Native Client OLE DB
โค๊ด: [Select]
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;


อ้างถึง
SQL Server Native Client 10.0 ODBC Driver
Type ODBC Driver
Usage Driver={SQL Server Native Client 10.0}
Manufacturer Microsoft

Standard security
โค๊ด: [Select]
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
Trusted Connection
โค๊ด: [Select]
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;
Connecting to an SQL Server instance
โค๊ด: [Select]
Driver={SQL Server Native Client 10.0};Server=myServerName\theInstanceName; Database=myDataBase;Trusted_Connection=yes;
Prompt for username and password
โค๊ด: [Select]
oConn.Properties("Prompt") = adPromptAlways

Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;

Enabling MARS (multiple active result sets)
โค๊ด: [Select]
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes; MARS_Connection=yes;
Encrypt data sent over network
โค๊ด: [Select]
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;Encrypt=yes;
Attach a database file on connect to a local SQL Server Express instance
โค๊ด: [Select]
Driver={SQL Server Native Client 10.0};Server=.\SQLExpress; AttachDbFilename=c:\asd\qwe\mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
โค๊ด: [Select]
Driver={SQL Server Native Client 10.0};Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;
Database mirroring
โค๊ด: [Select]
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Failover_Partner=myMirrorServerAddress;Database=myDataBase; Trusted_Connection=yes;


อ้างถึง
.NET Framework Data Provider for ODBC
Type .NET Framework Wrapper Class Library
Usage System.Data.Odbc.OdbcConnection
Manufacturer Microsoft

Bridging to SQL Native Client 10.0 ODBC Driver
โค๊ด: [Select]
Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;


อ้างถึง
SQLXML 4.0 OLEDB Provider
Type OLE DB Provider
Usage Provider=SQLXMLOLEDB.4.0;Data Provider=providername
Manufacturer Microsoft

Using SQL Server Native Client provider
โค๊ด: [Select]
Provider=SQLXMLOLEDB.4.0;Data Provider=SQLNCLI10;Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;


อ้างถึง
Context Connection
Type .NET Framework Class Library
Usage
Manufacturer Microsoft

Context Connection
โค๊ด: [Select]
C#
 using(SqlConnection connection = new SqlConnection("context connection=true"))
 {
     connection.Open();
     // Use the connection
 }

VB.Net
 Using connection as new SqlConnection("context connection=true")
     connection.Open()
     ' Use the connection
 End Using


สวัสดีคุณ ผู้เยี่ยมชม เข้าเว็บไซต์ DEKTAI2U.COM
Programming System & IT ZONE