/// <summary> /// 执行一条计算查询语句,返回查询结果(object)。 /// </summary> /// <param name="cmdText">查询语句</param> /// <param name="objParams">查询语句参数</param> /// <returns>返回结果</returns> public static object GetSingle(string cmdText, params ObjectParameter[] objParams) { object objResult = null; switch (DbType.ToLower()) { case "oracle": objResult = OracleDbHelper.GetSingle(DbConnectionString, FormatCommandText(cmdText), ObjectParamterToOracleParameter(objParams)); break; case "sql": objResult = SqlDbHelper.GetSingle(DbConnectionString, FormatCommandText(cmdText), ObjectParamterToSqlParameter(objParams)); break; } return(objResult); }
/// <summary> /// 检查记录是否存在 /// </summary> /// <param name="connString">数据库连接字符串</param> /// <param name="cmdText">查询语句</param> /// <param name="cmdParams">查询语句参数</param> /// <returns>返回结果</returns> public static bool Exists(string connString, string cmdText, params OracleParameter[] cmdParams) { object obj = OracleDbHelper.GetSingle(connString, cmdText, cmdParams); 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); } else { return(true); } }