1.與DB的connection開太多且用完後沒有關閉,導致connection pool已滿
2.dataReader 用完後沒有關閉
我的情況是兩種可能都有 XD
改掉之後程式就正常了
還有一種方法就是將connection pool加大
設定的方法就是在connectionString最後面加上Max pool size = 200
類似這樣
Server=myServerAddress;Database=myDataBase;Uid=myUsernamePwd=myPassword;Max pool size = 200
參考資料
補充說明:參考資料
Min pool size 代表在connection pool裡最少有幾個連接數,假設你Min pool size設5
那connection pool建立的時候,裡面就會有5個conncetion。
Max pool size則代表connection pool裡最多能有幾個connection。
如果connectioin已達到Max pool size且connection pool中的connection全部都在使用中,要打開新的SqlConnection物件時,則要等待一個SqlConnection物件關閉,然後才可以使用新的SqlConnection物件。如果請求等待時間超過ConnectionTimeout屬性指定的秒數,則會拋出exception。
2010年7月16日 星期五
.NET Data Providers
原出處
Microsoft SQL Server
MySQL - From CoreLab
ODBC Providers
OLE DB Providers
Oracle Provider - From Microsoft
Oracle Provider
- From Oracle
Oracle Provider
- From CoreLab
Postgre SQL Direct
- From CoreLab
Sybase ASE
VistaDB Provider
--------------------------------------------------------------------------------
Microsoft SQL Server .NET Data Provider (System.Data.SqlClient)
The Microsoft SQL Server .NET Data Provide allows you to connect to a Microsoft
SQL Server 7.0, 2000, and 2005 databases.
For Microsoft SQL Server 6.5 or earlier, use the OLE DB .NET Data Provider with
the SQL Server OLE DB
Provider (SQLOLEDB).
Using C#:
using System.Data.SqlClient; ... SqlConnection oSQLConn = new SqlConnection(); oSQLConn.ConnectionString = "Data Source=(local);" + "Initial Catalog=myDatabaseName;" + "Integrated Security=SSPI"; //Or // "Server=(local);" + // "Database=myDatabaseName;" + // "Trusted_Connection=Yes"; oSQLConn.Open(); ... oSQLConn.Close(); // If you open the connection, then close the connection! // Otherwise the connection does not go back into the connection pool. // Note the SqlDataAdapter will open and close the connection for you // when calling it's Fill or Update methods. However if the connection // is already open, the SqlDataAdapter will leave it 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;" & _ "Password=myPassword" oSQLConn.Open()
Where:
- "Network Library=DBMSSOCN" tells SqlClient to use TCP/IP
Q238949
- xxx.xxx.xxx.xxx is an IP address of the remote SQL Server.
- 1433 is the port number for the remote SQL Server.
Q269882 and
Q287932
- You can also add "Encrypt=yes" for
encryption
For more information, see:
SqlConnection Class,
Q308656, and
.NET Data Providers
To view Microsoft KB articles related to SQLClient,
click here
Note: Microsoft
SQLXML Managed Classes exposes the functionality of SQLXML inside the Microsoft
.NET Framework.
--------------------------------------------------------------------------------
MySQLDirect .NET Data Provider - From CoreLab (CoreLab.MySql)
MySQLDirect .NET is data provider to direct access to MySQL database server for
the Microsoft .NET Framework and .NET Compact Framework. It is completely based
on ActiveX Data Objects for the .NET Framework (ADO.NET) technology. ADO.NET provides
a rich set of components for creating distributed, data-sharing applications. It
is an integral part of the .NET Framework, providing access to relational data,
XML, and application data.
MySQLDirect .NET data provider can be used in the same way as the SQL Server .NET
or the OLE DB .NET Data Provider. Data provider can access MySQL server either using
native MySQL network protocol directly or through MySQL client library. It allows
to create lightweight and fast applications working with MySQL.
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. Download
here. Support forms
here.
--------------------------------------------------------------------------------
ODBC .NET Data Provider (System.Data.ODBC)
The Open Database Connectivity (ODBC) .NET Data Provider provides access to native
ODBC drivers the same way the OLE DB .NET Data Provider provides access to native
OLE DB providers.
Note: This namespace, class, or member is supported only in version
1.1 of the .NET Framework.
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;" 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.
--------------------------------------------------------------------------------
OLE DB .NET Data Provider (System.Data.OleDb)
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.
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.
--------------------------------------------------------------------------------
Oracle .NET Data Provider - From Microsoft (System.Data.OracleClient)
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 namespace, class, or member is supported only in version
1.1 of the .NET Framework.
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.
--------------------------------------------------------------------------------
Oracle .NET Data Provider - From Oracle (Oracle.DataAccess.Client)
The Oracle Data Provider for .NET (ODP.NET) features optimized data access to the
Oracle database from a .NET environment. ODP.NET allows developers to take advantage
of advanced Oracle database functionality, including Real Application Clusters,
XML DB, and advanced security. The data provider can be used from any .NET language,
including C# and Visual Basic .NET.
ODP.NET makes using Oracle from .NET more flexible, faster, and more stable. ODP.NET
includes many features not available from other .NET drivers, including Multiple
Active Result Sets (MARS), a native XML data type, the ability to bind array parameters,
and flexible LOB tuning. ODP.NET is designed for scalable enterprise Windows solutions
by providing full support for Unicode and local and distributed transactions. Distributed
transactions are supported using the Oracle Services for MTS.
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.
--------------------------------------------------------------------------------
OraDirect .NET Data Provider - From CoreLab (CoreLab.Oracle)
OraDirect .NET is a data provider to direct access to Oracle database server for
the Microsoft .NET Framework and .NET Compact Framework. It is completely based
on ActiveX Data Objects for the .NET Framework (ADO.NET) technology. ADO.NET provides
a rich set of components for creating distributed, data-sharing applications. It
is an integral part of the .NET Framework, providing access to relational data,
XML, and application data.
OraDirect .NET data provider can be used in the same way as the SQL Server .NET
or the OLE DB .NET Data Provider. OraDirect .NET can access Oracle server using
Oracle Call Interface (OCI) or through TCP/IP directly.
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.
Download here. id="dnn_ctr413_HtmlModule_HtmlHolder0"> Support forms
here.
--------------------------------------------------------------------------------
PostgreSQLDirect .NET Data Provider - From CoreLab (CoreLab.PostgreSql)
PostgreSQLDirect .NET is data provider to direct access to PostgreSQL database for
the Microsoft .NET Framework and .NET Compact Framework. It completely based on
ActiveX Data Objects for the .NET Framework (ADO.NET) technology. ADO.NET provides
a rich set of components for creating distributed, data-sharing applications. It
is an integral part of the .NET Framework, providing access to relational data,
XML, and application data.
PostgreSQLDirect .NET data provider can be used in the same way as the SQL Server
.NET or the OLE DB .NET Data Provider.
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. Download
here. Support forms
here.
--------------------------------------------------------------------------------
Sybase Adaptive Server (ASE) Enterprise .NET Data Provider ( name="AseClientManagedProvider">Sybase.Data.AseClient)
The ASE Enterprise .NET Data Provider is an
add-on component to the .NET 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.
--------------------------------------------------------------------------------
VistaDB (VistaDB.Provider)
The VistaDB
Provider allows you to access a VistaDB
database.
Using C#
using VistaDB.Provider; ... string connectionString = @"Data Source = C:\VistaDB.vdb3; Open Mode = ExclusiveReadWrite"; VistaDBConnection connection = new VistaDBConnection(connectionString); connection.Open();
Using VB.NET
Imports VistaDB.Provider ... Dim vistaDBConnection As VistaDBConnection = New VistaDBConnection() vistaDBConnection.ConnectionString = @"Data Source = C:\VistaDB.vdb3; Open Mode = ExclusiveReadWrite"; vistaDBConnection.Open()
For more information, see:
VistaDB On-line Help.
Microsoft SQL Server
MySQL - From CoreLab
ODBC Providers
OLE DB Providers
Oracle Provider - From Microsoft
Oracle Provider
- From Oracle
Oracle Provider
- From CoreLab
Postgre SQL Direct
- From CoreLab
Sybase ASE
VistaDB Provider
--------------------------------------------------------------------------------
Microsoft SQL Server .NET Data Provider (System.Data.SqlClient)
The Microsoft SQL Server .NET Data Provide allows you to connect to a Microsoft
SQL Server 7.0, 2000, and 2005 databases.
For Microsoft SQL Server 6.5 or earlier, use the OLE DB .NET Data Provider with
the SQL Server OLE DB
Provider (SQLOLEDB).
Using C#:
using System.Data.SqlClient; ... SqlConnection oSQLConn = new SqlConnection(); oSQLConn.ConnectionString = "Data Source=(local);" + "Initial Catalog=myDatabaseName;" + "Integrated Security=SSPI"; //Or // "Server=(local);" + // "Database=myDatabaseName;" + // "Trusted_Connection=Yes"; oSQLConn.Open(); ... oSQLConn.Close(); // If you open the connection, then close the connection! // Otherwise the connection does not go back into the connection pool. // Note the SqlDataAdapter will open and close the connection for you // when calling it's Fill or Update methods. However if the connection // is already open, the SqlDataAdapter will leave it 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;" & _ "Password=myPassword" oSQLConn.Open()
Where:
- "Network Library=DBMSSOCN" tells SqlClient to use TCP/IP
Q238949
- xxx.xxx.xxx.xxx is an IP address of the remote SQL Server.
- 1433 is the port number for the remote SQL Server.
Q269882 and
Q287932
- You can also add "Encrypt=yes" for
encryption
For more information, see:
SqlConnection Class,
Q308656, and
.NET Data Providers
To view Microsoft KB articles related to SQLClient,
click here
Note: Microsoft
SQLXML Managed Classes exposes the functionality of SQLXML inside the Microsoft
.NET Framework.
--------------------------------------------------------------------------------
MySQLDirect .NET Data Provider - From CoreLab (CoreLab.MySql)
MySQLDirect .NET is data provider to direct access to MySQL database server for
the Microsoft .NET Framework and .NET Compact Framework. It is completely based
on ActiveX Data Objects for the .NET Framework (ADO.NET) technology. ADO.NET provides
a rich set of components for creating distributed, data-sharing applications. It
is an integral part of the .NET Framework, providing access to relational data,
XML, and application data.
MySQLDirect .NET data provider can be used in the same way as the SQL Server .NET
or the OLE DB .NET Data Provider. Data provider can access MySQL server either using
native MySQL network protocol directly or through MySQL client library. It allows
to create lightweight and fast applications working with MySQL.
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. Download
here. Support forms
here.
--------------------------------------------------------------------------------
ODBC .NET Data Provider (System.Data.ODBC)
The Open Database Connectivity (ODBC) .NET Data Provider provides access to native
ODBC drivers the same way the OLE DB .NET Data Provider provides access to native
OLE DB providers.
Note: This namespace, class, or member is supported only in version
1.1 of the .NET Framework.
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;" 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.
--------------------------------------------------------------------------------
OLE DB .NET Data Provider (System.Data.OleDb)
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.
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.
--------------------------------------------------------------------------------
Oracle .NET Data Provider - From Microsoft (System.Data.OracleClient)
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 namespace, class, or member is supported only in version
1.1 of the .NET Framework.
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.
--------------------------------------------------------------------------------
Oracle .NET Data Provider - From Oracle (Oracle.DataAccess.Client)
The Oracle Data Provider for .NET (ODP.NET) features optimized data access to the
Oracle database from a .NET environment. ODP.NET allows developers to take advantage
of advanced Oracle database functionality, including Real Application Clusters,
XML DB, and advanced security. The data provider can be used from any .NET language,
including C# and Visual Basic .NET.
ODP.NET makes using Oracle from .NET more flexible, faster, and more stable. ODP.NET
includes many features not available from other .NET drivers, including Multiple
Active Result Sets (MARS), a native XML data type, the ability to bind array parameters,
and flexible LOB tuning. ODP.NET is designed for scalable enterprise Windows solutions
by providing full support for Unicode and local and distributed transactions. Distributed
transactions are supported using the Oracle Services for MTS.
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.
--------------------------------------------------------------------------------
OraDirect .NET Data Provider - From CoreLab (CoreLab.Oracle)
OraDirect .NET is a data provider to direct access to Oracle database server for
the Microsoft .NET Framework and .NET Compact Framework. It is completely based
on ActiveX Data Objects for the .NET Framework (ADO.NET) technology. ADO.NET provides
a rich set of components for creating distributed, data-sharing applications. It
is an integral part of the .NET Framework, providing access to relational data,
XML, and application data.
OraDirect .NET data provider can be used in the same way as the SQL Server .NET
or the OLE DB .NET Data Provider. OraDirect .NET can access Oracle server using
Oracle Call Interface (OCI) or through TCP/IP directly.
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.
Download here. id="dnn_ctr413_HtmlModule_HtmlHolder0"> Support forms
here.
--------------------------------------------------------------------------------
PostgreSQLDirect .NET Data Provider - From CoreLab (CoreLab.PostgreSql)
PostgreSQLDirect .NET is data provider to direct access to PostgreSQL database for
the Microsoft .NET Framework and .NET Compact Framework. It completely based on
ActiveX Data Objects for the .NET Framework (ADO.NET) technology. ADO.NET provides
a rich set of components for creating distributed, data-sharing applications. It
is an integral part of the .NET Framework, providing access to relational data,
XML, and application data.
PostgreSQLDirect .NET data provider can be used in the same way as the SQL Server
.NET or the OLE DB .NET Data Provider.
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. Download
here. Support forms
here.
--------------------------------------------------------------------------------
Sybase Adaptive Server (ASE) Enterprise .NET Data Provider ( name="AseClientManagedProvider">Sybase.Data.AseClient)
The ASE Enterprise .NET Data Provider is an
add-on component to the .NET 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.
--------------------------------------------------------------------------------
VistaDB (VistaDB.Provider)
The VistaDB
Provider allows you to access a VistaDB
database.
Using C#
using VistaDB.Provider; ... string connectionString = @"Data Source = C:\VistaDB.vdb3; Open Mode = ExclusiveReadWrite"; VistaDBConnection connection = new VistaDBConnection(connectionString); connection.Open();
Using VB.NET
Imports VistaDB.Provider ... Dim vistaDBConnection As VistaDBConnection = New VistaDBConnection() vistaDBConnection.ConnectionString = @"Data Source = C:\VistaDB.vdb3; Open Mode = ExclusiveReadWrite"; vistaDBConnection.Open()
For more information, see:
VistaDB On-line Help.
Oracle connection strings
Oracle ODBC connection strings
Open connection to Oracle database using ODBC
"Driver= {Microsoft ODBCforOracle};Server=Your_Oracle_Server.world;Uid=Your_Username;Pwd=Your_Password;"
Oracle OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to Oracle database with standard security:
1. "Provider=MSDAORA;Data Source= Your_Oracle_Database;UserId=Your_Username;Password=Your_Password;"
2. "Provider= OraOLEDB.Oracle;Your_Oracle_Database;UserId=Your_Username;Password=Your_Password;"
Open trusted connection to Oracle database
"Provider= OraOLEDB.Oracle;DataSource=Your_Oracle_Database;OSAuthent=1;"
Open connection to Oracle database using ODBC
"Driver= {Microsoft ODBCforOracle};Server=Your_Oracle_Server.world;Uid=Your_Username;Pwd=Your_Password;"
Oracle OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to Oracle database with standard security:
1. "Provider=MSDAORA;Data Source= Your_Oracle_Database;UserId=Your_Username;Password=Your_Password;"
2. "Provider= OraOLEDB.Oracle;Your_Oracle_Database;UserId=Your_Username;Password=Your_Password;"
Open trusted connection to Oracle database
"Provider= OraOLEDB.Oracle;DataSource=Your_Oracle_Database;OSAuthent=1;"
MySQL connection strings
MySQL ODBC connection strings
Open connection to local MySQL database using MySQL ODBC 3.51 Driver
"Provider=MSDASQL; DRIVER={MySQL ODBC 3.51Driver}; SERVER= localhost; DATABASE=Your_MySQL_Database; UID= Your_Username; PASSWORD=Your_Password; OPTION=3"
MySQL OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to MySQL database:
"Provider=MySQLProv;Data Source=Your_MySQL_Database;User Id=Your_Username; Password=Your_Password;"
Open connection to local MySQL database using MySQL ODBC 3.51 Driver
"Provider=MSDASQL; DRIVER={MySQL ODBC 3.51Driver}; SERVER= localhost; DATABASE=Your_MySQL_Database; UID= Your_Username; PASSWORD=Your_Password; OPTION=3"
MySQL OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to MySQL database:
"Provider=MySQLProv;Data Source=Your_MySQL_Database;User Id=Your_Username; Password=Your_Password;"
MS Access connection strings
MS Access ODBC connection strings
Standard Security:
"Driver= {MicrosoftAccessDriver(*.mdb)};DBQ=C:\App1\Your_Database_Name.mdb;Uid=Your_Username;Pwd=Your_Password;"
Workgroup:
"Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:\App1\Your_Database_Name.mdb; SystemDB=C:\App1\Your_Database_Name.mdw;"
Exclusive "Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\App1\Your_Database_Name.mdb; Exclusive=1; Uid=Your_Username; Pwd=Your_Password;"
MS Access OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to Access database:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; User Id=admin; Password="
Open connection to Access database using Workgroup (System database):
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:System Database=c:\App1\Your_System_Database_Name.mdw"
Open connection to password protected Access database:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:Database Password=Your_Password"
Open connection to Access database located on a network share:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\Server_Name\Share_Name\Share_Path\Your_Database_Name.mdb"
Open connection to Access database located on a remote server:
"Provider=MS Remote; Remote Server=http://Your-Remote-Server-IP; Remote Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb"
Standard Security:
"Driver= {MicrosoftAccessDriver(*.mdb)};DBQ=C:\App1\Your_Database_Name.mdb;Uid=Your_Username;Pwd=Your_Password;"
Workgroup:
"Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:\App1\Your_Database_Name.mdb; SystemDB=C:\App1\Your_Database_Name.mdw;"
Exclusive "Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\App1\Your_Database_Name.mdb; Exclusive=1; Uid=Your_Username; Pwd=Your_Password;"
MS Access OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to Access database:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; User Id=admin; Password="
Open connection to Access database using Workgroup (System database):
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:System Database=c:\App1\Your_System_Database_Name.mdw"
Open connection to password protected Access database:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:Database Password=Your_Password"
Open connection to Access database located on a network share:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\Server_Name\Share_Name\Share_Path\Your_Database_Name.mdb"
Open connection to Access database located on a remote server:
"Provider=MS Remote; Remote Server=http://Your-Remote-Server-IP; Remote Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\App1\Your_Database_Name.mdb"
SQL Server connection strings
SQL ODBC connection strings
Standard Security:< br> "Driver={SQLServer};Server=Your_Server_Name;Database=Your_Database_Name;Uid=Your_Username;Pwd=Your_Password;"
Trusted connection:< br> "Driver={SQLServer};Server=Your_Server_Name;Database=Your_Database_Name;Trusted_Connection=yes;"
SQL OLE DB connection strings
Standard Security:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog= Your_Database_Name;UserId=Your_Username;Password=Your_Password;"
Trusted connection:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
SQL OleDbConnection .NET strings
Standard Security:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog= Your_Database_Name;UserId=Your_Username;Password=Your_Password;"
Trusted connection:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
SQL SqlConnection .NET strings
Standard Security:
1. "Data Source=Your_Server_Name;Initial Catalog= Your_Database_Name;UserId=Your_Username;Password=Your_Password;" < br>2. "Server=Your_Server_Name;Database=Your_Database_Name;UserID=Your_Username;Password=Your_Password;Trusted_Connection=False"
Trusted connection:
1. "Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
2."Server=Your_Server_Name;Database=Your_Database_Name;Trusted_Connection=True;"
Standard Security:< br> "Driver={SQLServer};Server=Your_Server_Name;Database=Your_Database_Name;Uid=Your_Username;Pwd=Your_Password;"
Trusted connection:< br> "Driver={SQLServer};Server=Your_Server_Name;Database=Your_Database_Name;Trusted_Connection=yes;"
SQL OLE DB connection strings
Standard Security:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog= Your_Database_Name;UserId=Your_Username;Password=Your_Password;"
Trusted connection:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
SQL OleDbConnection .NET strings
Standard Security:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog= Your_Database_Name;UserId=Your_Username;Password=Your_Password;"
Trusted connection:
"Provider=SQLOLEDB;Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
SQL SqlConnection .NET strings
Standard Security:
1. "Data Source=Your_Server_Name;Initial Catalog= Your_Database_Name;UserId=Your_Username;Password=Your_Password;" < br>2. "Server=Your_Server_Name;Database=Your_Database_Name;UserID=Your_Username;Password=Your_Password;Trusted_Connection=False"
Trusted connection:
1. "Data Source=Your_Server_Name;Initial Catalog=Your_Database_Name;Integrated Security=SSPI;"
2."Server=Your_Server_Name;Database=Your_Database_Name;Trusted_Connection=True;"
2010年6月22日 星期二
訂閱:
文章 (Atom)

