/*
* Desinged by Jim Hui(惠永亮)
* Email :yonglianghui@163.com
* QQ:23011599
* Jiangsu China
* 2010-04-11
*/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
/// <summary>
/// dbc 的摘要说明
/// </summary>
public class dbc
{
public dbc()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
static string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "/App_Data/IFuGood.mdb";
static OleDbConnection con = new OleDbConnection(conStr);
public static DataTable ExecuteTable(string commandText, OleDbParameter[] paras)
{
DataSet ds = new DataSet();
try
{
con.Open();
OleDbCommand cmd = new OleDbCommand(commandText, con);
if (paras != null)
{
foreach (OleDbParameter para in paras)
{
cmd.Parameters.Add(para);
}
}
OleDbDataAdapter dap = new OleDbDataAdapter(cmd);
dap.Fill(ds);
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
finally
{
con.Close();
}
return ds.Tables[0];
}
public static void ExecuteNoQuery(string commandText, OleDbParameter[] paras)
{
try
{
con.Open();
OleDbCommand cmd = new OleDbCommand(commandText, con);
if (paras != null)
{
foreach (OleDbParameter para in paras)
{
cmd.Parameters.Add(para);
}
}
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
finally
{
con.Close();
}
}
public static object ExecuteScalar(string commandText, OleDbParameter[] paras)
{
object obj = new object();
try
{
con.Open();
OleDbCommand cmd = new OleDbCommand(commandText, con);
if (paras != null)
{
foreach (OleDbParameter para in paras)
{
cmd.Parameters.Add(para);
}
}
obj = cmd.ExecuteScalar();
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
finally
{
con.Close();
}
return obj;
}
}