ACCESS网站示例-连载-数据库操作类文件

时间:2022-06-14 12:55:51


using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
///ShuJuKu_ChaoZuo 的摘要说明:数据库操作
/// </summary>
public class ShuJuKu_ChaoZuo
{
public ShuJuKu_ChaoZuo()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
///ShuanChu_JiLu 的摘要说明:根据ID号、数据表名称、字段名称,删除数据库对应ID记录操作。
/// </summary>
public void ShuanChu_JiLu(string BiaoMing,string ZiDuanMing, int _ID)//删除记录
{
DataSet MyData = Socut.Data.ExecuteDataSet("DELETE FROM " + BiaoMing.Trim() + " WHERE " + ZiDuanMing.Trim() + "=" + _ID + "");
}

/// <summary>
///XianShi_ShenXu 的摘要说明:根据需要显示的条数、数据表名称、ID号,升序显示数据库对应记录操作。
/// </summary>
public DataSet XianShi_ShenXu(int TiaoShu, string BiaoMing, string _ID)//显示记录
{
DataSet Xian_Shi = Socut.Data.ExecuteDataSet("SELECT TOP " + TiaoShu + " * FROM " + BiaoMing.Trim() + "' order by " + _ID.Trim() + " asc");
return Xian_Shi;
}

/// <summary>
///XianShi_JianXu 的摘要说明:根据需要显示的条数、数据表名称、ID号,降序显示数据库对应记录操作。
/// </summary>
public DataSet XianShi_JianXu(int TiaoShu, string BiaoMing, string _ID)//显示记录
{
DataSet Xian_Shi = Socut.Data.ExecuteDataSet("SELECT TOP " + TiaoShu + " * FROM " + BiaoMing + "' order by " + _ID + " desc");
return Xian_Shi;
}

/// <summary>
///XianShi_JiLu1_JianXu 的摘要说明:根据需要显示的条数、数据表名称、字段名称、条件1、ID号,降序显示数据库对应条件记录操作。
/// </summary>
public DataSet XianShi_JiLu1_JianXu(int TiaoShu, string BiaoMing, string ZiDuanMing, string _TiaoJdian, string _ID)//显示记录
{
DataSet Xian_Shi = Socut.Data.ExecuteDataSet("SELECT TOP " + TiaoShu + " * FROM " + BiaoMing.Trim() + " WHERE " + ZiDuanMing.Trim() + "='" + _TiaoJdian.Trim() + "' order by " + _ID.Trim() + " desc");
return Xian_Shi;
}

/// <summary>
///XianShi_JiLu1_ShenXu 的摘要说明:根据需要显示的条数、数据表名称、字段名称、条件1、ID号,升序显示数据库对应条件记录操作。
/// </summary>
public DataSet XianShi_JiLu1_ShenXu(int TiaoShu, string BiaoMing, string ZiDuanMing, string _TiaoJdian, string _ID)//显示记录
{
DataSet Xian_Shi = Socut.Data.ExecuteDataSet("SELECT TOP " + TiaoShu + " * FROM " + BiaoMing.Trim() + " WHERE " + ZiDuanMing.Trim() + "='" + _TiaoJdian.Trim() + "' order by " + _ID.Trim() + " asc");
return Xian_Shi;
}

/// <summary>
///GenXin_JiLu 的摘要说明:根据数据表名称、字段名称、ID号,更新数据库对应条件记录操作。
/// </summary>
public void GenXin_JiLu(string BiaoMing, string ZiDuanMing,string _NeiRong, string _IDMing, int _ID)//更新记录
{
DataSet MyData = Socut.Data.ExecuteDataSet("UPDATE " + BiaoMing.Trim() + " SET " + ZiDuanMing.Trim() + "='" + _NeiRong.Trim() + "'WHERE " + _IDMing.Trim() + "=" + _ID + "");
}

/// <summary>
///GenXin_JiLu_BuEr 的摘要说明:根据数据表名称、字段名称、ID号,更新数据库对应条件的布尔记录操作。
/// </summary>
public void GenXin_JiLu_BuEr(string BiaoMing, string ZiDuanMing, bool _NeiRong, string _IDMing, int _ID)//更新记录
{
DataSet MyData = Socut.Data.ExecuteDataSet("UPDATE " + BiaoMing.Trim() + " SET " + ZiDuanMing.Trim() + "='" + _NeiRong + "'WHERE " + _IDMing.Trim() + "=" + _ID + "");
}

/// <summary>
///GenXin_JiLu_ZiDuanTiaoJian 的摘要说明:根据数据表名称、字段名称、字段条件,更新数据库对应条件记录操作。
/// </summary>
public void GenXin_JiLu_ZiDuanTiaoJian(string BiaoMing, string ZiDuanMing, string _NeiRong, string ZiDuan_Ming, string ZiDuan_TiaoJian)//更新记录
{
DataSet MyData = Socut.Data.ExecuteDataSet("UPDATE " + BiaoMing.Trim() + " SET " + ZiDuanMing.Trim() + "='" + _NeiRong.Trim() + "'WHERE " + ZiDuan_Ming.Trim() + "='" + ZiDuan_TiaoJian.Trim() + "'");
}

/// <summary>
///XieRu_JiLu 的摘要说明:根据数据表名称、字段名称,数据库对应字段循环写入,创建一条记录操作。
/// </summary>
public void XieRu_JiLu(string BiaoMing, string[] ZiDuanMing, string[] _NeiRong)//创建记录
{
Socut.Data.ExecuteScalar("INSERT INTO " + BiaoMing.Trim() + " (" + ZiDuanMing[0].Trim() + ") VALUES ('" + "@!#$" + "')");
for (int i = 1; i < ZiDuanMing.Length; i++)
{
GenXin_JiLu_ZiDuanTiaoJian(BiaoMing, ZiDuanMing[i].Trim(), _NeiRong[i].Trim(), ZiDuanMing[0].Trim(), "@!#$");
}
GenXin_JiLu_ZiDuanTiaoJian(BiaoMing, ZiDuanMing[0].Trim(), _NeiRong[0].Trim(), ZiDuanMing[0].Trim(), "@!#$");
}

/// <summary>
///DuQu_JiLu_DengYu 的摘要说明:根据数据表名称、字段名称、条件1,读取数据库等于条件记录操作,默认排序。
/// </summary>
public Socut.Reader DuQu_JiLu_DengYu(string BiaoMing, string ZiDuanMing, string _NeiRong)//读取记录
{
Socut.Reader DuQuJiLu = new Socut.Reader("SELECT * FROM " + BiaoMing.Trim() + " WHERE " + ZiDuanMing.Trim() + "='" + _NeiRong.Trim() + "'");
return DuQuJiLu;
}

/// <summary>
///DuQu_JiLu_DengYu_JianXu 的摘要说明:根据数据表名称、字段名称、条件1、ID号,读取数据库全等于条件记录操作,降序。
/// </summary>
public Socut.Reader DuQu_JiLu_DengYu_JianXu(string BiaoMing, string ZiDuanMing, string _NeiRong, string _ID)//读取记录
{
Socut.Reader DuQuJiLu = new Socut.Reader("SELECT * FROM " + BiaoMing.Trim() + " WHERE " + ZiDuanMing.Trim() + "='" + _NeiRong.Trim() + "'order by " + _ID.Trim() + " desc");
return DuQuJiLu;
}

/// <summary>
///DuQu_JiLu_DengYu_ShenXu 的摘要说明:根据数据表名称、字段名称、条件1、ID号,读取数据库全等于条件记录操作,升序。
/// </summary>
public Socut.Reader DuQu_JiLu_DengYu_ShenXu(string BiaoMing, string ZiDuanMing, string _NeiRong, string _ID)//读取记录
{
Socut.Reader DuQuJiLu = new Socut.Reader("SELECT * FROM " + BiaoMing.Trim() + " WHERE " + ZiDuanMing.Trim() + "='" + _NeiRong.Trim() + "'order by " + _ID.Trim() + " asc");
return DuQuJiLu;
}

/// <summary>
///DuQu_JiLu_* 的摘要说明:根据数据表名称、字段名称、条件1,读取数据库模糊条件记录操作,默认排序。
/// </summary>
public Socut.Reader DuQu_JiLu_*(string BiaoMing, string ZiDuanMing, string _NeiRong)//读取记录
{
Socut.Reader DuQuJiLu = new Socut.Reader("SELECT * FROM " + BiaoMing.Trim() + " WHERE " + ZiDuanMing.Trim() + " like '" + _NeiRong.Trim() + "'");
return DuQuJiLu;
}

/// <summary>
///DuQu_JiLu_Quan* 的摘要说明:根据数据表名称、字段名称、条件1,读取数据库全模糊条件记录操作,默认排序。
/// </summary>
public Socut.Reader DuQu_JiLu_Quan*(string BiaoMing, string ZiDuanMing, string _NeiRong)//读取记录
{
Socut.Reader DuQuJiLu = new Socut.Reader("SELECT * FROM " + BiaoMing.Trim() + " WHERE " + ZiDuanMing.Trim() + " like '%" + _NeiRong.Trim() + "%'");
return DuQuJiLu;
}

/// <summary>
///DuQu_JiLu_QuanXian 的摘要说明:根据数据表名称、字段名称与条件3(登陆名称、密码、验证的[与]逻辑),登陆系统。
/// </summary>
public Socut.Reader DuQu_JiLu_QuanXian(string BiaoMing, string MingChen, string MingChen_NeiRong, string MiMa, string MiMa_NeiRong, string YanZhen, string YanZhen_NeiRong)//登陆系统
{
Socut.Reader DenLu = new Socut.Reader("SELECT * FROM " + BiaoMing.Trim() + " WHERE " + MingChen.Trim() + " = '" + MingChen_NeiRong.Trim() + "' and " + MiMa.Trim() + " = '" + MiMa_NeiRong.Trim() + "' and " + YanZhen.Trim() + " = '" + YanZhen_NeiRong.Trim() + "'");
return DenLu;
}

/// <summary>
///DuQu_TiaoShu 的摘要说明:根据数据表名称,读取数据库数据总条数操作。
/// </summary>
public int DuQu_TiaoShu(string BiaoMing)//读取记录条数
{
int DuQuTiaoShu = (int)Socut.Data.ExecuteScalar("SELECT COUNT(*) FROM " + BiaoMing + "");
return DuQuTiaoShu;
}

}