Sqlhleper 帮助类的编写过程和注意事项
要满足的基本的ADO.NET的sql执行语句!
一、基本的runsql 有几种返回类型的执行结果!
都是通过sqlcommand来实现 com.ExecuteNonQuery();返回的只有整型 所以满足两种要求就行!
com.ExecuteNonQuery();
一就是有直接运行传递过来的sql语句并返回是否执行成功
public boolExecuteNonQuery(string sql)
{
intindex = 0;
open();
using(SqlCommand com = CreateSqlCommand(sql, null))
{
try
{
index =com.ExecuteNonQuery();
}
catch(Exception ex)
{
CommonClass.EorrorLog(ex.Message);
}
}
close();
returnindex > 0 ? true : false;
}
二有参数的sql语句这里要带入参数 有参数的传入就要有创建参数的一个方法这样可以避免以后有参数时大量代码的重复!
public boolExecuteNonQuery(string sql,SqlParameter[] pars)
{
intindex = 0;
open();
using(SqlCommand com = CreateSqlCommand(sql, pars))
{
try
{
index =com.ExecuteNonQuery();
}
catch(Exception ex)
{
CommonC