首先:先给大家提供一部分资源。方便有困难的同仁查找资料
Adaptive Server Enterprise (ASE)
.NET Data Provider
Sybase.Data.AseClient
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();
MySQLDirect .NET Data Provider
CoreLab.MySql
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();
ODBC .NET Data Provider
System.Data.ODBC
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
Using C#:
using System.Data.OracleClient;
OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString = "Data Source=Oracle8i;" +
"Integrated Security=SSPI";
oOracleConn.Open();
Oracle .NET Data Provider - From Oracle
Oracle.DataAccess.Client
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 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();
MySQL .NET Data Provider
EID.MySqlClient
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();
PostgreSQLDirect .NET Data Provider
CoreLab.PostgreSql
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();
SQL Server .NET Data Provider
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 connectcion for you// when calling it's Fill or Update methods. However if the connection// is already open, the SqlDataAdapter will leave it open.
最后:想说的是我想用C#程序连接Sysbase 数据库。但不想通过ODBC来连接。因为这样每当客户重新装系统后,都需要重新配置。但客户计算机水平很一般。这样对我们的售后带来很大麻烦。所以现在想直接通过C#数据库连接字符串的方法来用程序实现。所以现在就涉及一个命名空间的问题:using Sybase.Data.AseClient。。我必须在后台的数据库低层类。应用这个命名空间。我才能象SqlServer一样的使用字符串形式的连接。但我用了这个以后。系统就编译不过去。说找不到该命名空间。所以现在请问大家该如何解决这个问题。希望大侠给帮助。大家一起进步。 谢谢。
Adaptive Server Enterprise (ASE)
.NET Data Provider
Sybase.Data.AseClient
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();
MySQLDirect .NET Data Provider
CoreLab.MySql
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();
ODBC .NET Data Provider
System.Data.ODBC
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
Using C#:
using System.Data.OracleClient;
OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString = "Data Source=Oracle8i;" +
"Integrated Security=SSPI";
oOracleConn.Open();
Oracle .NET Data Provider - From Oracle
Oracle.DataAccess.Client
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 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();
MySQL .NET Data Provider
EID.MySqlClient
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();
PostgreSQLDirect .NET Data Provider
CoreLab.PostgreSql
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();
SQL Server .NET Data Provider
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 connectcion for you// when calling it's Fill or Update methods. However if the connection// is already open, the SqlDataAdapter will leave it open.
最后:想说的是我想用C#程序连接Sysbase 数据库。但不想通过ODBC来连接。因为这样每当客户重新装系统后,都需要重新配置。但客户计算机水平很一般。这样对我们的售后带来很大麻烦。所以现在想直接通过C#数据库连接字符串的方法来用程序实现。所以现在就涉及一个命名空间的问题:using Sybase.Data.AseClient。。我必须在后台的数据库低层类。应用这个命名空间。我才能象SqlServer一样的使用字符串形式的连接。但我用了这个以后。系统就编译不过去。说找不到该命名空间。所以现在请问大家该如何解决这个问题。希望大侠给帮助。大家一起进步。 谢谢。
可以使用using System.Data.OleDb