调用例子:
1> 得到记录数
/// <summary>
/// 得到记录数
/// </summary>
/// <returns>返回int</returns>
public static int getWB_SYS_UserCount(string sWhere)
{
int iCount = 0;
try
{
using EMESqlHelper es = new EMESqlHelper())
{
iCount = es.GetRecordCount("WB_SYS_User", sWhere);
}
return iCount;
}
catch (Exception ex)
{
throw ex;
}
}
2> 带返回参数的存储过程调用(注意其中的InputOutput类型)
/// <summary>
/// 新增数据
/// </summary>
/// <param name="_obj">WB_SYS_UserEnt实体</param>
/// <returns>返回bool值</returns>
public static bool WB_SYS_UserAdd(WB_SYS_UserEnt _obj)
{
//*******************定义并赋值参数数组*******************//
SqlParameter[] arParms = new SqlParameter[9];
arParms[0] = new SqlParameter("AdminGroupID", SqlDbType.Int, 4);
arParms[0].Direction = ParameterDirection.Input;
arParms[0].Value = _obj.AdminGroupID;
arParms[1] = new SqlParameter("Username", SqlDbType.NChar, 40);
arParms[1].Direction = ParameterDirection.Input;
arParms[1].Value = _obj.Username;
arParms[2] = new SqlParameter("Password", SqlDbType.NChar, 64);
arParms[2].Direction = ParameterDirection.Input;
arParms[2].Value = _obj.Password;
arParms[3] = new SqlParameter("RealName", SqlDbType.VarChar, 20);
arParms[3].Direction = ParameterDirection.Input;
arParms[3].Value = _obj.RealName;
arParms[4] = new SqlParameter("MobileNum", SqlDbType.VarChar, 20);
arParms[4].Direction = ParameterDirection.Input;
arParms[4].Value = _obj.MobileNum;
arParms[5] = new SqlParameter("PasswordAsk", SqlDbType.VarChar, 200);
arParms[5].Direction = ParameterDirection.Input;
arParms[5].Value = _obj.PasswordAsk;
arParms[6] = new SqlParameter("PasswordAnswer", SqlDbType.VarChar, 200);
arParms[6].Direction = ParameterDirection.Input;
arParms[6].Value = _obj.PasswordAnswer;
arParms[7] = new SqlParameter("Creater", SqlDbType.VarChar, 20);
arParms[7].Direction = ParameterDirection.Input;
arParms[7].Value = _obj.Creater;
bool Exist = false;
arParms[8] = new SqlParameter("Exist", SqlDbType.Bit, 1);
arParms[8].Direction = ParameterDirection.InputOutput;
arParms[8].Value = Exist;
try
{
using EMESqlHelper es = new EMESqlHelper())
{
es.ExecCommand("WB_SYS_User_Add", "1", arParms);
Exist = (bool)arParms[8].Value;
}
return !Exist;
}
catch (Exception ex)
{
throw ex;
}
}
其中关联类SqlDataBase和DataBase的代码如下: