.NET Data Provider

  •  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

  • The ASE .NET Data Provider is an add-on component to the .NET 1.1 Framework that allows you to access a Sybase Adaptive Server Enterprise (ASE) database.
    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.NET
    Imports System.Data.AseClient
    ...
    Dim oAseConn As AseConnection = New AseConnection()
    oAseConn.ConnectionString = "Data Source=(local);" & _
    "Initial Catalog=myDatabaseName;" & _
    "User ID=myUsername;" & _
    "Password=myPassword"
    oAseConn.Open()
    For more information, see:  ASE User's Guide

    The MySQLDirect .NET Data Provider is an add-on component to the
    .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;

    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();
    Using VB.NET
    Imports CoreLab.MySql

    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()
    For more information, see:   CoreLab's MySqlDirect .NET Data Provider

    The Open Database Connectivity (ODBC) .NET Data Provider is an add-on component to the .NET Framework. It provides access to native ODBC drivers the same way the OLE DB .NET Data Provider provides access to native OLE DB providers.
    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
    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()
    For Oracle ODBC Driver
    ' VB.NET
    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()
    For Access (JET) ODBC Driver
    ' VB.NET
    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()
    For Sybase System 11 ODBC Driver
    ' VB.NET
    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()
    For all other ODBC Drivers
    ' VB.NET
    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()
    For more information, see:  OdbcConnection Class and .NET Data Providers
    To view Microsoft KB articles related to OdbcConnection, click here 

    The Microsoft .NET Framework Data Provider for OLE DB allow you to use native OLE DB providers (e.g.  Microsoft.JET.OLEDB.4.0) through COM interop to enable data access. 
    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
    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()
    For JET OLE DB Provider
    ' VB.NET
    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()
    For Oracle OLE DB Provider
    ' VB.NET
    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()
    For SQL Server OLE DB Provider
    ' VB.NET
    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()
    For Sybase ASE OLE DB Provider
    ' VB.NET
    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()
    For more information, see:  OleDbConnection Class and .NET Data Providers
    To view Microsoft KB articles related to OleDbConnection, click here 

    The Microsoft .NET Framework Data Provider for Oracle is an add-on component to the .NET Framework 1.0 that provides access to an Oracle database using the Oracle Call Interface (OCI) as provided by Oracle Client software.
    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;

    OracleConnection oOracleConn = new OracleConnection();
    oOracleConn.ConnectionString = "Data Source=Oracle8i;" +
    "Integrated Security=SSPI";
    oOracleConn.Open();
    Using VB.NET:
    Imports System.Data.OracleClient

    Dim oOracleConn As OracleConnection = New OracleConnection()
    oOracleConn.ConnectionString = "Data Source=Oracle8i;" & _
    "Integrated Security=SSPI";
    oOracleConn.Open()
    For more information, see:   OracleConnection Class and .NET Data Providers
    To view Microsoft KB articles related to OracleConnection, click here 

    The Oracle .NET Framework Data Provider from Oracle is an add-on component to the .NET Framework.
    Using C#
    using Oracle.DataAccess.Client;
    ...
    OracleConnection oOracleConn = new OracleConnection();
    oOracleConn.ConnectionString = "Data Source=MyOracleServerName;" +
    "Integrated Security=SSPI";
    oOracleConn.Open();
    Using VB.NET
    Imports Oracle.DataAccess.Client
    ...
    Dim oOracleConn As OracleConnection = New OracleConnection()
    oOracleConn.ConnectionString = "Data Source=MyOracleServerName;" & _
    "Integrated Security=SSPI";
    oOracleConn.Open()
    For more information, see: Oracle Data Provider for .NET

    The OraDirect .NET Data Provider is an add-on component to the .NET
    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

    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()
    For more information, see:  OraDirect .NET Data Provider

    The MySQL .NET Native Provider is an add-on component to the .NET Framework that allows you to access the MySQL database through
     the native protocol, without going through OLE DB or ODBC.
    Using C#
    using EID.MySqlClient;
    ...
    MySqlConnection oMySqlConn = new MySqlConnection();
    oMySqlConn.ConnectionString = "Data Source=(local);" +
    "Database=myDatabaseName;" +
    "User ID=myUsername;" +
    "Password=myPassword;" +
    "Command Logging=false";
    oMySqlConn.Open();
    Using VB.NET
    Imports EID.MySqlClient
    ...
    Dim oMySqlConn As MySqlConnection = New MySqlConnection()
    oMySqlConn.ConnectionString = "Data Source=(local);" & _
    "Database=myDatabaseName;" & _
    "User ID=myUsername;" & _
    "Password=myPassword;" & _
    "Command Logging=false"
    oMySqlConn.Open()
    For more information, see:   EID's MySQL ADO.NET native provider

    The PostgreSQLDirect .NET Data Provider is an add-on component to the
    .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

    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()
    For more information, see:   PostgreSQLDirect .NET Data Provider

    The SQL Server .NET Data Provide allows you to connect to a Microsoft SQL Server 7.0 or 2000 database.  For Microsoft SQL Server 6.5 or earlier, use the OLE DB .NET Data Provider with  the "SQL Server OLE DB Provider" (SQLOLEDB).
    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;
    ...
    SqlConnection oSQLConn = new SqlConnection();
    oSQLConn.ConnectionString = "Data Source=(local);" +
    "Initial Catalog=myDatabaseName;" +
    "Integrated Security=SSPI";
    oSQLConn.Open();
    Using VB.NET:
    Imports System.Data.SqlClient
    ...
    Dim oSQLConn As SqlConnection = New SqlConnection()
    oSQLConn.ConnectionString = "Data Source=(local);" & _
    "Initial Catalog=myDatabaseName;" & _
    "Integrated Security=SSPI"
    oSQLConn.Open()
    If connection to a remote server (via IP address):
    oSQLConn.ConnectionString = "Network Library=DBMSSOCN;" & _
    "Data Source=xxx.xxx.xxx.xxx,1433;" & _
    "Initial Catalog=myDatabaseName;" & _
    "User ID=myUsername;" & _
    "Pas sword=myPassword"
    Where: 
    - "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 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值