using System;
using System.Data;
using System.Data.OracleClient;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace ASPNETClassLibrary
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// Command_ORACLE 的摘要说明。
/// </summary>
public class Command_ORACLE
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
public Command_ORACLE()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
//
// TODO: 在此处添加构造函数逻辑
//
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...#region
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 连接数据字段
/// </summary>
private static string _connectionString;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 设置为只读
/// </summary>
public static string connectionString
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
get
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
return _connectionString;
}
set
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
_connectionString = value;
}
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 打开数据的连接
/// </summary>
/// <returns></returns>
public static OracleConnection getOracleConnection()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
try
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
string OracleString = _connectionString ; //"Provider=Microsoft.Jet.Oracle.4.0;User ID=Admin;Data Source='" + HttpContext.Current.Server.MapPath("~/LHB_DataBase/LHB.mdb") + "';Jet Oracle:Engine Type=5;Jet Oracle:Database Locking Mode=1;Jet Oracle:Global Partial Bulk Ops=2;Jet Oracle:Global Bulk Transactions=1;Jet Oracle:Create System Database=False;Jet Oracle:Encrypt Database=False;Jet Oracle:Don't Copy Locale on Compact=False;Jet Oracle:Compact Without Replica Repair=False;Jet Oracle:SFP=False";
OracleConnection oc = new OracleConnection(OracleString);
oc.Open();
return oc;
}
catch(Exception ex)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
string temp = ex.Message;
return null;
}
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 获取 OracleCommand 对象
/// </summary>
/// <returns></returns>
public static OracleCommand getOracleCommand()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
OracleConnection cn = getOracleConnection();
if (cn == null)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
return null;
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
OracleCommand cmd = new OracleCommand();
cmd.Connection = cn;
return cmd;
}
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 新建一个DataSet对象
/// </summary>
/// <param name="ExecuteString">要执行的语句,可是Oracle语句,也可是存储过程的名称</param>
/// <returns></returns>
public static DataSet getDataSet(string ExecuteString)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
OracleConnection cn = getOracleConnection();
OracleDataAdapter odda = new OracleDataAdapter(ExecuteString,cn);
DataSet ds = new DataSet();
if (cn == null)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
return null;
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
odda.Fill(ds);
return ds;
}
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 新建一个DataSet对象
/// </summary>
/// <param name="ExecuteString">要执行的语句,可是Oracle语句,也可是存储过程的名称</param>
/// <param name="name">表的名字</param>
/// <returns></returns>
public static DataSet getDataSet(string ExecuteString, string name)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
OracleConnection cn = getOracleConnection();
OracleDataAdapter odda = new OracleDataAdapter(ExecuteString,cn);
DataSet ds = new DataSet();
if (cn == null)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
return null;
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
odda.Fill(ds,name);
return ds;
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 新建一个DataSet对象
/// </summary>
/// <param name="ExecuteString">要执行的语句,可是Oracle语句,也可是存储过程的名称</param>
/// <returns></returns>
public static DataTable getDataTable(string ExecuteString)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
OracleConnection cn = getOracleConnection();
OracleDataAdapter odda = new OracleDataAdapter(ExecuteString,cn);
DataTable dt = new DataTable();
if (cn == null)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
return null;
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
odda.Fill(dt);
return dt;
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 执行Oracle语句,返回受影响的行数,
/// -2 说明数据连接失败,
/// -3 发生异常错误。
/// </summary>
/// <param name="ExecuteString">要执行的语句,可是Oracle语句,也可是存储过程的名称</param>
/// <returns></returns>
public static int ExecuteNonQuery(string ExecuteString)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
int count;
OracleCommand cmd = getOracleCommand();
if (cmd == null)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 说明数据连接失败
/// <summary>
return -2;
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 把要执行的字符串给LHB_CMD
/// <summary>
cmd.CommandText = ExecuteString;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 开始执行
/// <summary>
count = cmd.ExecuteNonQuery();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 返回一个值.
/// <summary>
return count;
}
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 执行指定的Oracle语句,返回首行首列
/// -2 说明数据连接失败,
/// -3 发生异常错误。
/// </summary>
/// <param name="ExecuteString">要执行的语句,可是Oracle语句,也可是存储过程的名称</param>
/// <returns>返回首行首列的那个值</returns>
public static string ExecuteScalar(string ExecuteString)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
try
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
string ShouHangShouLie;
OracleCommand cmd = getOracleCommand();
if (cmd == null)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
return "-2";
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
cmd.CommandText = ExecuteString;
ShouHangShouLie = cmd.ExecuteScalar().ToString();
return ShouHangShouLie;
}
}
catch (Exception LHB_EE)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
string temp = LHB_EE.Message;
return "-3";
}
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
#endregion
}
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)