没有合适的资源?快使用搜索试试~ 我知道了~
NET SQL Server数据访问抽象基础类
需积分: 10 5 下载量 181 浏览量
2009-06-06
01:39:27
上传
评论
收藏 29KB TXT 举报
温馨提示
试读
27页
C#中数据访问抽象基础类,包括执行简单SQL语句,设置命令的执行等待时间 执行多条SQL语句,实现数据库事务。 执行带一个存储过程参数的的SQL语句。 。。。。。等等
资源推荐
资源详情
资源评论
DbHelperSQL.CS
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
/// <summary>
/// 数据访问抽象基础类
/// 2008-9-30
/// </summary>
public abstract class DbHelperSQL
{
//数据库连接字符串(web.config来配置)
public static string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
public DbHelperSQL()
{
}
#region 公用方法
/// <summary>
/// 获取表中字段中最大数
/// </summary>
/// <param name="FieldName">字段名</param>
/// <param name="TableName">表名</param>
/// <returns></returns>
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
/// <summary>
/// 数据访问抽象基础类
/// 2008-9-30
/// </summary>
public abstract class DbHelperSQL
{
//数据库连接字符串(web.config来配置)
public static string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
public DbHelperSQL()
{
}
#region 公用方法
/// <summary>
/// 获取表中字段中最大数
/// </summary>
/// <param name="FieldName">字段名</param>
/// <param name="TableName">表名</param>
/// <returns></returns>
public static int GetMaxID(string FieldName, string TableName)
{
string strsql = "select max(" + FieldName + ")+1 from " + TableName;
object obj = DbHelperSQL.GetSingle(strsql);
if (obj == null)
{
return 1;
}
else
{
return int.Parse(obj.ToString());
}
}
public static bool Exists(string strSql)
{
object obj = DbHelperSQL.GetSingle(strSql);
int cmdresult;
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
{
cmdresult = 0;
}
else
{
cmdresult = int.Parse(obj.ToString());
}
if (cmdresult == 0)
{
return false;
}
{
string strsql = "select max(" + FieldName + ")+1 from " + TableName;
object obj = DbHelperSQL.GetSingle(strsql);
if (obj == null)
{
return 1;
}
else
{
return int.Parse(obj.ToString());
}
}
public static bool Exists(string strSql)
{
object obj = DbHelperSQL.GetSingle(strSql);
int cmdresult;
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
{
cmdresult = 0;
}
else
{
cmdresult = int.Parse(obj.ToString());
}
if (cmdresult == 0)
{
return false;
}
剩余26页未读,继续阅读
资源评论
qq286560526
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功