无为清净楼资源网 Design By www.qnjia.com
文章内容为本站编辑,创作.你可以任意转载、发布、使用但请务必以明文标注文章原始出处及本声明 http://www.opent.cn 作者:浪淘沙
此贴的方法会持续更新, 此文件要引用与数据操作的基类
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;
namespace EC
{
/// <summary>
/// EB通用与数据交互操作基类
/// </summary>
public class EBCommonObj:IDisposable
{
private bool _alreadyDispose = false;
private DBOperate dbo;
private string sql = null;
private System.Data.DataSet ds;
#region 构造与析构函数
public EBCommonObj()
{
dbo = new DBOperate();
}
~EBCommonObj()
{
dbo.Dispose();
Dispose();
}
protected virtual void Dispose(bool isDisposing)
{
if (_alreadyDispose) return;
if (isDisposing)
{
dbo.Dispose();
}
_alreadyDispose = true;
}
#endregion
#region IDisposable 成员
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
#region 通用删除数据库中的某条记录
/// <summary>
/// 通用删除数据库中的某条记录
/// </summary>
/// <param name="tbl">数据表名</param>
/// <param name="fld">字段名</param>
/// <param name="IsInt">是否是int型</param>
/// <param name="kev">关键词值</param>
public void CommDelByID(string tbl, string fld, bool IsInt, string key)
{
sql = "delete from {0} where {1}=";
if (IsInt)
{
sql += "{3}";
}
else
{
sql += "'{3}'";
}
dbo.ExecuteNonQuery(string.Format(sql, tbl, fld, IsInt, key));
}
#endregion
#region 通用读取数据库中的某条记录
/// <summary>
/// 通用读取数据库中的某条记录
/// </summary>
/// <param name="tbl"></param>
/// <param name="fld"></param>
/// <param name="IsInt"></param>
/// <param name="key"></param>
/// <returns></returns>
public DataSet CommReadByID(string tbl,string fld,bool IsInt,string key)
{
sql = "select * from {0} where {1}=";
if (IsInt)
{
sql += "{3}";
}
else
{
sql += "'{3}'";
}
ds = dbo.GetDataSet(string.Format(sql, tbl, fld, IsInt, key));
return ds;
}
#endregion
#region 修改数据库中的某条记录为true 或flase
/// <summary>
/// 修改数据库中的某条记录为true 或flase
/// </summary>
/// <param name="tbl">表格式</param>
/// <param name="fld">主键标识</param>
/// <param name="Isint">是否整形</param>
/// <param name="key">主键</param>
/// <param name="flgfld">flase键</param>
/// <param name="flgkey">key值</param>
public void CommUpdateByID(string tbl,string fld,bool Isint,string key,string flgfld,int flgkey)
{
sql = "update {0} set {4}={5} where {1}=";
if (Isint)
{
sql += "{3}";
}
else
{
sql += "'{3}'";
}
dbo.ExecuteNonQuery(string.Format(sql, tbl, fld, Isint, key, flgfld, flgkey));
}
#endregion
#region 绑定DropDown 列表
/// <summary>
/// 绑定DropDown 列表
/// </summary>
/// <param name="tbl">表名</param>
/// <param name="selValue">下拉框值</param>
/// <param name="selText">下拉框显示内容</param>
/// <param name="strWhere">where 条件语句 不用加where 没有条件则为空</param>
/// <param name="dr">DropDownList控件名称</param>
public void DropBind(string tbl, string selValue, string selText, string strWhere,System.Web.UI.WebControls.DropDownList dr)
{
ds = GetDrop(tbl, selValue, selText, strWhere);
dr.DataSource = ds;
dr.DataTextField = selText;
dr.DataValueField = selValue;
dr.DataBind();
ds.Clear();
ds.Dispose();
}
/// <summary>
/// 读取表中数据
/// </summary>
/// <param name="tbl"></param>
/// <param name="selValue"></param>
/// <param name="selText"></param>
/// <param name="strWhere">条件</param>
/// <returns></returns>
public DataSet GetDrop(string tbl,string selValue,string selText,string strWhere)
{
sql = "select {1},{2} from {0} where 1=1 and {3}";
ds = dbo.GetDataSet(string.Format(sql, tbl, selValue, selText, strWhere));
return ds;
}
#endregion
#region 判断是否有数据
/// <summary>
/// 判断是否有数据:存在数据时返回true,否则返回Flash
/// </summary>
/// <param name="tbl">数据表名</param>
/// <param name="fld">字段名</param>
/// <param name="key">关键词</param>
/// <param name="IsKeyInt">是否是数字类型:是:true;否:false</param>
/// <returns>true或false</returns>
public bool IsHaveDate(string tbl,string fld,string key,bool IsKeyInt)
{
bool Rev = false;
if (IsKeyInt)
{
sql = "select * from {0} where {1}={2}";
}
else
{
sql = "select * from {0} where {1}='{2}'";
}
ds = dbo.GetDataSet(string.Format(sql, tbl, fld, key));
if (ds.Tables[0].Rows.Count > 0)
{
Rev = true;
}
return Rev;
}
#endregion
}
}
/############################################
版权声明:
文章内容为本站编辑,创作.你可以任意转载、发布、使用但请务必标明文章原始出处及本声明
http://www.opent.cn 作者:浪淘沙
############################################/
/**********************************************************************************
*
* 功能说明:数据操作基类,可以执行内联SQL语句和存储过程
* 作者: 刘功勋;
* 版本:V0.1(C#2.0);时间:2006-4-28
*
* *******************************************************************************/
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace EC
{
/// <summary>
/// 数据库连接及操作对象类
/// </summary>
public class DBBase
{
private bool _alreadyDispose = false;
private System.Data.SqlClient.SqlConnection conn;
private System.Data.SqlClient.SqlCommand com;
#region 构造与柝构
public DBBase()
{
try
{
conn=new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
conn.Open();
com = new System.Data.SqlClient.SqlCommand();
com.Connection = conn;
}
catch (Exception ee)
{
throw new Exception("连接数据库出错");
}
}
~DBBase()
{
Dispose();
}
protected virtual void Dispose(bool isDisposing)
{
if (_alreadyDispose) return;
if (isDisposing)
{
// TODO: 此处释放受控资源
if (com != null)
{
com.Cancel();
com.Dispose();
}
if (conn != null)
{
try
{
conn.Close();
conn.Dispose();
}
catch (Exception ee)
{
}
finally
{
conn = null;
}
}
}
// TODO: 此处释放非受控资源。设置被处理过标记
_alreadyDispose = true;
}
#endregion
#region IDisposable 成员
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
#region 数据基本操作
/// <summary>
/// ExecuteNonQuery
/// </summary>
/// <param name="sqlString">SQL语句</param>
/// <returns>返回影响行数</returns>
public int ExecuteNonQuery(string sqlString)
{
int ret = 0;
com.CommandText = sqlString;
com.CommandType = CommandType.Text;
try
{
ret = com.ExecuteNonQuery();
}
catch (Exception ee)
{
throw new Exception("SQL:" + sqlString + "<br />" + ee.Message.ToString());
}
finally
{
com.Cancel();
}
return ret;
}
/// <summary>
/// 执行插入语句返回IDENTITY
/// </summary>
/// <param name="sqlString">SQL语句</param>
/// <returns>@@IDENTITY</returns>
public int ExecInsert(string sqlString)
{
int identity = 0;
//仅能执行Insert into 语句
if (!sqlString.ToLower().Contains("insert into"))
{
return -1;
}
sqlString += " Select @@IDENTITY";
System.Data.DataSet ds = new DataSet();
try
{
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(sqlString, conn);
da.Fill(ds);
da.Dispose();
}
catch (Exception ee)
{
throw new Exception("SQL:" + sqlString + "<br />" + ee.Message.ToString());
}
if (ds.Tables[0].Rows.Count > 0)
{
identity =Convert.ToInt32(ds.Tables[0].Rows[0][0]);
}
ds.Clear();
ds.Dispose();
return identity;
}
/// <summary>
/// 执行SQL语句返回记录集
/// </summary>
/// <param name="sqlString">SQL语句</param>
/// <returns>DataSet</returns>
public DataSet GetDataSet(string sqlString)
{
System.Data.DataSet ds = new DataSet();
try
{
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(sqlString, conn);
da.Fill(ds);
da.Dispose();
}
catch (Exception ee)
{
throw new Exception("SQL:" + sqlString + "<br />" + ee.Message.ToString());
}
return ds;
}
/// <summary>
/// 执行存储过程(返回N种参数)
/// </summary>
/// <param name="procName">过程名</param>
/// <param name="hashtable">传入的参数表</param>
/// <param name="hashtable1">传出的参数表</param>
/// <returns>返回参数表</returns>
public System.Collections.Hashtable ExecProcedure(string procName, System.Collections.Hashtable hashtable, System.Collections.Hashtable hashtable1)
{
System.Collections.Hashtable hashtable2 = new System.Collections.Hashtable();
System.Collections.IDictionaryEnumerator ide = hashtable.GetEnumerator();
System.Collections.IDictionaryEnumerator ide1 = hashtable1.GetEnumerator();
com.CommandType = CommandType.StoredProcedure;
com.CommandText = procName;
while (ide.MoveNext())
{
System.Data.SqlClient.SqlParameter p = new System.Data.SqlClient.SqlParameter(ide.Key.ToString(), ide.Value);
com.Parameters.Add(p);
}
while (ide1.MoveNext())
{
System.Data.SqlClient.SqlParameter p = new System.Data.SqlClient.SqlParameter(ide1.Key.ToString(), ide.Value);
com.Parameters.Add(p);
}
try
{
com.ExecuteNonQuery();
ide1 = hashtable1.GetEnumerator();
while (ide1.MoveNext())
{
string k = ide1.Key.ToString();
hashtable2.Add(k, com.Parameters[k].Value);
}
}
catch (Exception ee)
{
throw new Exception(ee.Message.ToString());
}
finally
{
com.Cancel();
}
return hashtable2;
}
12下一页阅读全文
此贴的方法会持续更新, 此文件要引用与数据操作的基类
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;
namespace EC
{
/// <summary>
/// EB通用与数据交互操作基类
/// </summary>
public class EBCommonObj:IDisposable
{
private bool _alreadyDispose = false;
private DBOperate dbo;
private string sql = null;
private System.Data.DataSet ds;
#region 构造与析构函数
public EBCommonObj()
{
dbo = new DBOperate();
}
~EBCommonObj()
{
dbo.Dispose();
Dispose();
}
protected virtual void Dispose(bool isDisposing)
{
if (_alreadyDispose) return;
if (isDisposing)
{
dbo.Dispose();
}
_alreadyDispose = true;
}
#endregion
#region IDisposable 成员
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
#region 通用删除数据库中的某条记录
/// <summary>
/// 通用删除数据库中的某条记录
/// </summary>
/// <param name="tbl">数据表名</param>
/// <param name="fld">字段名</param>
/// <param name="IsInt">是否是int型</param>
/// <param name="kev">关键词值</param>
public void CommDelByID(string tbl, string fld, bool IsInt, string key)
{
sql = "delete from {0} where {1}=";
if (IsInt)
{
sql += "{3}";
}
else
{
sql += "'{3}'";
}
dbo.ExecuteNonQuery(string.Format(sql, tbl, fld, IsInt, key));
}
#endregion
#region 通用读取数据库中的某条记录
/// <summary>
/// 通用读取数据库中的某条记录
/// </summary>
/// <param name="tbl"></param>
/// <param name="fld"></param>
/// <param name="IsInt"></param>
/// <param name="key"></param>
/// <returns></returns>
public DataSet CommReadByID(string tbl,string fld,bool IsInt,string key)
{
sql = "select * from {0} where {1}=";
if (IsInt)
{
sql += "{3}";
}
else
{
sql += "'{3}'";
}
ds = dbo.GetDataSet(string.Format(sql, tbl, fld, IsInt, key));
return ds;
}
#endregion
#region 修改数据库中的某条记录为true 或flase
/// <summary>
/// 修改数据库中的某条记录为true 或flase
/// </summary>
/// <param name="tbl">表格式</param>
/// <param name="fld">主键标识</param>
/// <param name="Isint">是否整形</param>
/// <param name="key">主键</param>
/// <param name="flgfld">flase键</param>
/// <param name="flgkey">key值</param>
public void CommUpdateByID(string tbl,string fld,bool Isint,string key,string flgfld,int flgkey)
{
sql = "update {0} set {4}={5} where {1}=";
if (Isint)
{
sql += "{3}";
}
else
{
sql += "'{3}'";
}
dbo.ExecuteNonQuery(string.Format(sql, tbl, fld, Isint, key, flgfld, flgkey));
}
#endregion
#region 绑定DropDown 列表
/// <summary>
/// 绑定DropDown 列表
/// </summary>
/// <param name="tbl">表名</param>
/// <param name="selValue">下拉框值</param>
/// <param name="selText">下拉框显示内容</param>
/// <param name="strWhere">where 条件语句 不用加where 没有条件则为空</param>
/// <param name="dr">DropDownList控件名称</param>
public void DropBind(string tbl, string selValue, string selText, string strWhere,System.Web.UI.WebControls.DropDownList dr)
{
ds = GetDrop(tbl, selValue, selText, strWhere);
dr.DataSource = ds;
dr.DataTextField = selText;
dr.DataValueField = selValue;
dr.DataBind();
ds.Clear();
ds.Dispose();
}
/// <summary>
/// 读取表中数据
/// </summary>
/// <param name="tbl"></param>
/// <param name="selValue"></param>
/// <param name="selText"></param>
/// <param name="strWhere">条件</param>
/// <returns></returns>
public DataSet GetDrop(string tbl,string selValue,string selText,string strWhere)
{
sql = "select {1},{2} from {0} where 1=1 and {3}";
ds = dbo.GetDataSet(string.Format(sql, tbl, selValue, selText, strWhere));
return ds;
}
#endregion
#region 判断是否有数据
/// <summary>
/// 判断是否有数据:存在数据时返回true,否则返回Flash
/// </summary>
/// <param name="tbl">数据表名</param>
/// <param name="fld">字段名</param>
/// <param name="key">关键词</param>
/// <param name="IsKeyInt">是否是数字类型:是:true;否:false</param>
/// <returns>true或false</returns>
public bool IsHaveDate(string tbl,string fld,string key,bool IsKeyInt)
{
bool Rev = false;
if (IsKeyInt)
{
sql = "select * from {0} where {1}={2}";
}
else
{
sql = "select * from {0} where {1}='{2}'";
}
ds = dbo.GetDataSet(string.Format(sql, tbl, fld, key));
if (ds.Tables[0].Rows.Count > 0)
{
Rev = true;
}
return Rev;
}
#endregion
}
}
/############################################
版权声明:
文章内容为本站编辑,创作.你可以任意转载、发布、使用但请务必标明文章原始出处及本声明
http://www.opent.cn 作者:浪淘沙
############################################/
/**********************************************************************************
*
* 功能说明:数据操作基类,可以执行内联SQL语句和存储过程
* 作者: 刘功勋;
* 版本:V0.1(C#2.0);时间:2006-4-28
*
* *******************************************************************************/
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace EC
{
/// <summary>
/// 数据库连接及操作对象类
/// </summary>
public class DBBase
{
private bool _alreadyDispose = false;
private System.Data.SqlClient.SqlConnection conn;
private System.Data.SqlClient.SqlCommand com;
#region 构造与柝构
public DBBase()
{
try
{
conn=new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
conn.Open();
com = new System.Data.SqlClient.SqlCommand();
com.Connection = conn;
}
catch (Exception ee)
{
throw new Exception("连接数据库出错");
}
}
~DBBase()
{
Dispose();
}
protected virtual void Dispose(bool isDisposing)
{
if (_alreadyDispose) return;
if (isDisposing)
{
// TODO: 此处释放受控资源
if (com != null)
{
com.Cancel();
com.Dispose();
}
if (conn != null)
{
try
{
conn.Close();
conn.Dispose();
}
catch (Exception ee)
{
}
finally
{
conn = null;
}
}
}
// TODO: 此处释放非受控资源。设置被处理过标记
_alreadyDispose = true;
}
#endregion
#region IDisposable 成员
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
#region 数据基本操作
/// <summary>
/// ExecuteNonQuery
/// </summary>
/// <param name="sqlString">SQL语句</param>
/// <returns>返回影响行数</returns>
public int ExecuteNonQuery(string sqlString)
{
int ret = 0;
com.CommandText = sqlString;
com.CommandType = CommandType.Text;
try
{
ret = com.ExecuteNonQuery();
}
catch (Exception ee)
{
throw new Exception("SQL:" + sqlString + "<br />" + ee.Message.ToString());
}
finally
{
com.Cancel();
}
return ret;
}
/// <summary>
/// 执行插入语句返回IDENTITY
/// </summary>
/// <param name="sqlString">SQL语句</param>
/// <returns>@@IDENTITY</returns>
public int ExecInsert(string sqlString)
{
int identity = 0;
//仅能执行Insert into 语句
if (!sqlString.ToLower().Contains("insert into"))
{
return -1;
}
sqlString += " Select @@IDENTITY";
System.Data.DataSet ds = new DataSet();
try
{
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(sqlString, conn);
da.Fill(ds);
da.Dispose();
}
catch (Exception ee)
{
throw new Exception("SQL:" + sqlString + "<br />" + ee.Message.ToString());
}
if (ds.Tables[0].Rows.Count > 0)
{
identity =Convert.ToInt32(ds.Tables[0].Rows[0][0]);
}
ds.Clear();
ds.Dispose();
return identity;
}
/// <summary>
/// 执行SQL语句返回记录集
/// </summary>
/// <param name="sqlString">SQL语句</param>
/// <returns>DataSet</returns>
public DataSet GetDataSet(string sqlString)
{
System.Data.DataSet ds = new DataSet();
try
{
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(sqlString, conn);
da.Fill(ds);
da.Dispose();
}
catch (Exception ee)
{
throw new Exception("SQL:" + sqlString + "<br />" + ee.Message.ToString());
}
return ds;
}
/// <summary>
/// 执行存储过程(返回N种参数)
/// </summary>
/// <param name="procName">过程名</param>
/// <param name="hashtable">传入的参数表</param>
/// <param name="hashtable1">传出的参数表</param>
/// <returns>返回参数表</returns>
public System.Collections.Hashtable ExecProcedure(string procName, System.Collections.Hashtable hashtable, System.Collections.Hashtable hashtable1)
{
System.Collections.Hashtable hashtable2 = new System.Collections.Hashtable();
System.Collections.IDictionaryEnumerator ide = hashtable.GetEnumerator();
System.Collections.IDictionaryEnumerator ide1 = hashtable1.GetEnumerator();
com.CommandType = CommandType.StoredProcedure;
com.CommandText = procName;
while (ide.MoveNext())
{
System.Data.SqlClient.SqlParameter p = new System.Data.SqlClient.SqlParameter(ide.Key.ToString(), ide.Value);
com.Parameters.Add(p);
}
while (ide1.MoveNext())
{
System.Data.SqlClient.SqlParameter p = new System.Data.SqlClient.SqlParameter(ide1.Key.ToString(), ide.Value);
com.Parameters.Add(p);
}
try
{
com.ExecuteNonQuery();
ide1 = hashtable1.GetEnumerator();
while (ide1.MoveNext())
{
string k = ide1.Key.ToString();
hashtable2.Add(k, com.Parameters[k].Value);
}
}
catch (Exception ee)
{
throw new Exception(ee.Message.ToString());
}
finally
{
com.Cancel();
}
return hashtable2;
}
12下一页阅读全文
标签:
Asp.Net,数据操作类
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
2024年11月17日
2024年11月17日
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO
- 群星《继续微笑致敬许冠杰》[低速原抓WAV+CUE]
- 潘秀琼.2003-国语难忘金曲珍藏集【皇星全音】【WAV+CUE】
- 林东松.1997-2039玫瑰事件【宝丽金】【WAV+CUE】