/// <summary> /// run sql return object values /// </summary> /// <param name="sql"></param> /// <returns></returns> public static int RunSQLReturnIntVal(string sql) { string str = DBAccessOfOracle2.RunSQLReturnVal(sql).ToString(); try { return(int.Parse(str)); } catch (Exception ex) { throw new Exception("RunSQLReturnIntVal 9i =" + ex.Message + " str = " + str); } }
/// <summary> /// run sql return decimal val /// </summary> /// <param name="sql"></param> /// <returns></returns> public static decimal RunSQLReturnDecimalVal(string sql) { object obj = DBAccessOfOracle2.RunSQLReturnVal(sql); if (obj == null) { throw new Exception("@执行方法DBAccessOfOracle2.RunSQLReturnDecimalVal()错误,运行的结果是null.请检查sql=" + sql); } try { return(decimal.Parse(obj.ToString())); } catch { throw new Exception("@执行方法DBAccessOfOracle2.RunSQLReturnDecimalVal()错误,运行的结果是[" + obj + "].不能向decimal 转换,请检查sql=" + sql); } }
/// <summary> /// run sql return float values. /// </summary> /// <param name="sql">will run sql</param> /// <returns>values</returns> public static float RunSQLReturnFloatVal(string sql) { object obj = DBAccessOfOracle2.RunSQLReturnVal(sql); if (obj.ToString() == "System.DBNull") { throw new Exception("@执行方法DBAccessOfOracle2.RunSQLReturnFloatVal(sql)错误,运行的结果是null.请检查sql=" + sql); } try { return(float.Parse(obj.ToString())); } catch { throw new Exception("@执行方法DBAccessOfOracle2.RunSQLReturnFloatVal(sql)错误,运行的结果是[" + obj.ToString() + "].不能向float 转换,请检查sql=" + sql); } }
/// <summary> /// run sql return decimal. /// </summary> /// <param name="sql"></param> /// <param name="isNullAsVal"></param> /// <returns></returns> public static decimal RunSQLReturnDecimalVal(string sql, decimal isNullAsVal) { object obj = DBAccessOfOracle2.RunSQLReturnVal(sql); try { System.DBNull dbnull = (System.DBNull)obj; return(isNullAsVal); } catch { } try { return(decimal.Parse(obj.ToString())); } catch { throw new Exception("@执行方法DBAccessOfOracle2.RunSQLReturnDecimalVal(sql,isNullAsVal)错误,运行的结果是[" + obj + "].不能向float 转换,请检查sql=" + sql); } }