Ejemplo n.º 1
0
    /// <summary>
    /// 获取SQL语句执行的第一行第一列的值
    /// </summary>
    /// <param name="strSql">SQL语句</param>
    /// <returns>SQL语句执行的第一行第一列的值</returns>
    public static object ExecuteScalar(string strSql)
    {
        DbCore dbCore = null;
        object obj    = null;

        try
        {
            dbCore = new DbCore(GetDatabaseType(), GetConnectionString());
            dbCore.Open();
            obj = dbCore.ExecuteScalar(strSql);
            dbCore.Close();
            return(obj);
        }
        catch (Exception ex)
        {
            if (dbCore != null)
            {
                dbCore.Close();
            }
            throw ex;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 快速执行一不带参数的存储过程
    /// </summary>
    /// <param name="strStoredProcedureName">存储过程名称</param>
    /// <returns>存储过程执行后受影响的行数</returns>
    public static int ExecuteStoredProcedure(string strStoredProcedureName)
    {
        DbCore dbCore = null;

        try
        {
            dbCore = new DbCore(GetDatabaseType(), GetConnectionString());
            dbCore.Open();
            return(dbCore.ExecuteStoredProcedure(strStoredProcedureName));
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            if (dbCore != null)
            {
                dbCore.Close();
            }
        }
    }