- ASE .NET Data Provider
- MySQLDirect .NET Data Provider
- ODBC .NET Data Provider
- OLE DB .NET Data Provider
- Oracle .NET Data Provider - From Microsoft
- Oracle .NET Data Provider - From Oracle
- OraDirect .NET Data Provider
- PostgreSQLDirect .NET Data Provider
- SQL Server .NET Data Provider
-
- Adaptive Server Enterprise (ASE)
.NET Data Provider
Sybase.Data.AseClient
Using C#
using Sybase.Data.AseClient;
...
AseConnection oAseConn = new AseConnection();
oAseConn.ConnectionString = "Data Source=(local);" +
"Initial Catalog=myDatabaseName;" +
"User ID=myUsername;" +
"Password=myPassword"
oAseConn.Open();
Using VB.NETImports System.Data.AseClient
For more information, see: ASE User's Guide
...
Dim oAseConn As AseConnection = New AseConnection()
oAseConn.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=myDatabaseName;" & _
"User ID=myUsername;" & _
"Password=myPassword"
oAseConn.Open()
- MySQLDirect .NET Data Provider
CoreLab.MySql
.NET Framework that allows you to access the MySQL database using
native MySQL network protocol or MySQL client, without going through
OLE DB or ODBC.
Using C#
using CoreLab.MySql;
Using VB.NET
MySqlConnection oMySqlConn = new MySqlConnection();
oMySqlConn.ConnectionString = "User ID=myUsername;" +
"Password=myPassword;" +
"Host=localhost;" +
"Port=3306;" +
"Database=myDatabaseName;" +
"Direct=true;" +
"Protocol=TCP;" +
"Compress=false;" +
"Pooling=true;" +
"Min Pool Size=0;" +
"Max Pool Size=100;" +
"Connection Lifetime=0";
oMySqlConn.Open();
Imports CoreLab.MySql
For more information, see: CoreLab's MySqlDirect .NET Data Provider
Dim oMySqlConn As MySqlConnection = New MySqlConnection()
oMySqlConn.ConnectionString = "User ID=myUsername;" & _
"Password=myPassword;" & _
"Host=localhost;" & _
"Port=3306;" & _
"Database=myDatabaseName;" & _
"Direct=true;" & _
"Protocol=TCP;" & _
"Compress=false;" & _
"Pooling=true;" & _
"Min Pool Size=0;" & _
"Max Pool Size=100;" & _
"Connection Lifetime=0"
oMySqlConn.Open()
- ODBC .NET Data Provider
System.Data.ODBC
Note: This technology is included in version 1.1 of the .NET Framework. You need only download this, if you are running version 1.0.
For SQL Server ODBC Driver
' VB.NET
For Oracle ODBC Driver
Imports System.Data.Odbc
...
Dim oODBCConnection As OdbcConnection
Dim sConnString As String = _
"Driver={SQL Server};" & _
"Server=MySQLServerName;" & _
"Database=MyDatabaseName;" & _
"Uid=MyUsername;" & _
"Pwd=MyPassword"
oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()
' VB.NET
For Access (JET) ODBC Driver
Imports System.Data.Odbc
...
Dim oODBCConnection As OdbcConnection
Dim sConnString As String = _
"Driver={Microsoft ODBC for Oracle};" & _
"Server=OracleServer.world;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"
oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()
' VB.NET
For Sybase System 11 ODBC Driver
Imports System.Data.Odbc
...
Dim oODBCConnection As OdbcConnection
Dim sConnString As String = _
"Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:/somepath/mydb.mdb;" & _
"Uid=Admin;" & _
"Pwd="
oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()
' VB.NET
For all other ODBC Drivers
Imports System.Data.Odbc
...
Dim oODBCConnection As OdbcConnection
Dim sConnString As String = _
"Driver={Sybase System 11};" & _
"SRVR=mySybaseServerName;" & _
"DB=myDatabaseName;" & _
"UID=myUsername;" & _
"PWD=myPassword"
oODBCConnection = New OdbcConnection(sConnString)
oODBCConnection.Open()
' VB.NET
For more information, see: OdbcConnection Class and .NET Data Providers
Imports System.Data.Odbc
...
Dim oODBCConnection As OdbcConnection
Dim sConnString As String = "Dsn=myDsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"
oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()
To view Microsoft KB articles related to OdbcConnection, click here
- OLE DB .NET Data Provider
System.Data.OleDb
The Microsoft .NET Framework Data Provider for OLE DB is included in both the 1.0 and 1.1 version of the .NET Framework.
For IBM AS/400 OLE DB Provider
' VB.NET
For JET OLE DB Provider
Imports System.Data.OleDb
...
Dim oOleDbConnection As OleDbConnection
Dim sConnString As String = _
"Provider=IBMDA400.DataSource.1;" & _
"Data source=myAS400DbName;" & _
"User Id=myUsername;" & _
"Password=myPassword"
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()
' VB.NET
For Oracle OLE DB Provider
Imports System.Data.OleDb
...
Dim oOleDbConnection As OleDbConnection
Dim sConnString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:/myPath/myJet.mdb;" & _
"User ID=Admin;" & _
"Password="
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()
' VB.NET
For SQL Server OLE DB Provider
Imports System.Data.OleDb
...
Dim oOleDbConnection As OleDbConnection
Dim sConnString As String = _
"Provider=OraOLEDB.Oracle;" & _
"Data Source=MyOracleDB;" & _
"User ID=myUsername;" & _
"Password=myPassword"
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()
' VB.NET
For Sybase ASE OLE DB Provider
Imports System.Data.OleDb
...
Dim oOleDbConnection As OleDbConnection
Dim sConnString As String = _
"Provider=sqloledb;" & _
"Data Source=myServerName;" & _
"Initial Catalog=myDatabaseName;" & _
"User Id=myUsername;" & _
"Password=myPassword"
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()
' VB.NET
For more information, see: OleDbConnection Class and .NET Data Providers
Imports System.Data.OleDb
...
Dim oOleDbConnection As OleDbConnection
Dim sConnString As String = _
"Provider=Sybase ASE OLE DB Provider;" & _
"Data Source=MyDataSourceName;" & _
"Server Name=MyServerName;" & _
"Database=MyDatabaseName;" & _
"User ID=myUsername;" & _
"Password=myPassword"
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()
To view Microsoft KB articles related to OleDbConnection, click here
- Oracle .NET Data Provider - From Microsoft
System.Data.OracleClient
Oracle 8i Release 3 (8.1.7) Client or later must be installed for this provider to function correctly.
Note: This .NET Data Provider is included in version 1.1 of the .NET Framework. You need only download this, if you are running version 1.0.
Using C#:
using System.Data.OracleClient;
Using VB.NET:
OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString = "Data Source=Oracle8i;" +
"Integrated Security=SSPI";
oOracleConn.Open();
Imports System.Data.OracleClient
For more information, see: OracleConnection Class and .NET Data Providers
Dim oOracleConn As OracleConnection = New OracleConnection()
oOracleConn.ConnectionString = "Data Source=Oracle8i;" & _
"Integrated Security=SSPI";
oOracleConn.Open()
To view Microsoft KB articles related to OracleConnection, click here
- Oracle .NET Data Provider - From Oracle
Oracle.DataAccess.Client
Using C#
using Oracle.DataAccess.Client;
Using VB.NET
...
OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString = "Data Source=MyOracleServerName;" +
"Integrated Security=SSPI";
oOracleConn.Open();
Imports Oracle.DataAccess.Client
For more information, see: Oracle Data Provider for .NET
...
Dim oOracleConn As OracleConnection = New OracleConnection()
oOracleConn.ConnectionString = "Data Source=MyOracleServerName;" & _
"Integrated Security=SSPI";
oOracleConn.Open()
- OraDirect .NET Data Provider - From CoreLab
CoreLab.Oracle
Framework that provides access to an Oracle database using the Oracle
Call Interface (OCI) as provided by Oracle Client software.
Using C#
using CoreLab.Oracle;
OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString = "User ID=myUsername;" +
"Password=myPassword;" +
"Host=(local);" +
"Pooling=true;" +
"Min Pool Size=0;" +
"Max Pool Size=100;" +
"Connection Lifetime=0";
oOracleConn.Open();
Using VB.NET
Imports CoreLab.Oracle
For more information, see: OraDirect .NET Data Provider
Dim oOracleConn As OracleConnection = New OracleConnection()
oOracleConn.ConnectionString = "User ID=myUsername;" & _
"Password=myPassword;" & _
"Host=(local);" & _
"Pooling=true;" & _
"Min Pool Size=0;" & _
"Max Pool Size=100;" & _
"Connection Lifetime=0"
oOracleConn.Open()
- MySQL .NET Data Provider
EID.MySqlClient
the native protocol, without going through OLE DB or ODBC.
Using C#
using EID.MySqlClient;
Using VB.NET
...
MySqlConnection oMySqlConn = new MySqlConnection();
oMySqlConn.ConnectionString = "Data Source=(local);" +
"Database=myDatabaseName;" +
"User ID=myUsername;" +
"Password=myPassword;" +
"Command Logging=false";
oMySqlConn.Open();
Imports EID.MySqlClient
For more information, see: EID's MySQL ADO.NET native provider
...
Dim oMySqlConn As MySqlConnection = New MySqlConnection()
oMySqlConn.ConnectionString = "Data Source=(local);" & _
"Database=myDatabaseName;" & _
"User ID=myUsername;" & _
"Password=myPassword;" & _
"Command Logging=false"
oMySqlConn.Open()
- PostgreSQLDirect .NET Data Provider
CoreLab.PostgreSql
.NET Framework that allows you to access the PostgreSQL database using
native message-based protocol, without going through OLE DB or ODBC.
Using C#
using CoreLab.PostgreSql;
PgSqlConnection oPgSqlConn = new PgSqlConnection();
oPgSqlConn.ConnectionString = "User ID=myUsername;" +
"Password=myPassword;" +
"Host=localhost;" +
"Port=5432;" +
"Database=myDatabaseName;" +
"Pooling=true;" +
"Min Pool Size=0;" +
"Max Pool Size=100;" +
"Connection Lifetime=0";
oPgSqlConn.Open();
Using VB.NET
Imports CoreLab.PostgreSql
For more information, see: PostgreSQLDirect .NET Data Provider
Dim oPgSqlConn As PgSqlConnection = New PgSqlConnection()
oPgSqlConn.ConnectionString = "User ID=myUsername;" & _
"Password=myPassword;" & _
"Host=localhost;" & _
"Port=5432;" & _
"Database=myDatabaseName;" & _
"Pooling=true;" & _
"Min Pool Size=0;" & _
"Max Pool Size=100;" & _
"Connection Lifetime=0"
oPgSqlConn.Open()
- SQL Server .NET Data Provider
System.Data.SqlClient
Note: The SQL Server .NET Data Provider knows which data provider it is. Hence the "provider=" part of the connection string is not needed.
Using C#:
using System.Data.SqlClient;
Using VB.NET:
...
SqlConnection oSQLConn = new SqlConnection();
oSQLConn.ConnectionString = "Data Source=(local);" +
"Initial Catalog=myDatabaseName;" +
"Integrated Security=SSPI";
oSQLConn.Open();
Imports System.Data.SqlClient
If connection to a remote server (via IP address):
...
Dim oSQLConn As SqlConnection = New SqlConnection()
oSQLConn.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=myDatabaseName;" & _
"Integrated Security=SSPI"
oSQLConn.Open()
oSQLConn.ConnectionString = "Network Library=DBMSSOCN;" & _
Where:
"Data Source=xxx.xxx.xxx.xxx,1433;" & _
"Initial Catalog=myDatabaseName;" & _
"User ID=myUsername;" & _
"Pas sword=myPassword"
- "Network Library=DBMSSOCN" tells SqlConnection to use TCP/IP Q238949
- xxx.xxx.xxx.xxx is an IP address.
- 1433 is the default port number for SQL Server. Q269882 and Q287932
- You can also add " Encrypt=yes" for encryption
For more information, see: SqlConnection Class, Q308656, and .NET Data Providers
Note: Microsoft SQLXML Managed Classes exposes the functionality of SQLXML inside the Microsoft .NET Framework.
To view Microsoft KB articles related to SQLClient, click here - Adaptive Server Enterprise (ASE)
.NET Data Provider
最新推荐文章于 2024-08-13 08:38:20 发布