日期:2014-05-17 浏览次数:20825 次
string sqlcon="Data source=ORCL;user=erp;password=123456";
string sqlcom="select * from table";
DataTable dt=ExecuteGetTable(sqlcon,sqlcom);//得到数据集
//定义一个连接方法
public static DataTable ExecuteGetTable(string connectionString, string cmdText)
{
DataTable dt = null;
using (OracleConnection conn = new OracleConnection(connectionString))
{
try
{
OracleDataAdapter oda = new OracleDataAdapter(cmdText, conn);
dt = new DataTable();
oda.Fill(dt);
}
catch
{
conn.Close();
throw;
}
}
return dt;