예제 #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;
        }
    }