ADO
連接到 SQL Server
SQL Server
復制代碼代碼如下:
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection
// Do work here
}
連接到 OLE DB 數據源
OLE DB
復制代碼代碼如下:
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
connection
// Do work here
}
連接到 ODBC 數據源
ODBC
復制代碼代碼如下:
using (OdbcConnection connection = new OdbcConnection(connectionString))
{
connection
// Do work here
}
連接到 Oracle 數據源
Oracle
復制代碼代碼如下:
using (OracleConnection connection = new OracleConnection(connectionString))
{
connection
// Do work here
}
OracleConnection nwindConn = new OracleConnection("Data Source=MyOracleServer;Integrated Security=yes;");
nwindConn
以下是連接實例
ACCESS
復制代碼代碼如下:
stringconStr=@"provider=microsoft
SQL SERVER
復制代碼代碼如下:
stringconStr=@"Server=bwj;database=demo;uid=sa;pwd=";
ORACLE
復制代碼代碼如下:
stringconStr=@"Provider=MSDAORA
From:http://tw.wingwit.com/Article/program/net/201311/14230.html