mysql c#分页通过存储过程和out参数同时获得总数和表

       return SQLHelper.ExecuteReaderAndCount(SQLHelper.ConnectioinString, CommandType.StoredProcedure, "call GetMediaInfoNewNoApprove(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,@count)", out count,getMediaByRd, par);

 

/// <summary>         /// 带总数量的查询         /// </summary>         /// <param name="connectionString"></param>         /// <param name="cmdType"></param>         /// <param name="cmdText"></param>         /// <param name="commandParameters"></param>         /// <returns></returns>         public static DataTable ExecuteReaderAndCount(string connectionString, CommandType cmdType, string cmdText, out int count,gettablebyRd gettable, params OdbcParameter[] commandParameters)         {             OdbcCommand cmd = new OdbcCommand();             OdbcConnection conn = new OdbcConnection(connectionString);

            // we use a try/catch here because if the method throws an exception we want to             // close the connection throw code, because no datareader will exist, hence the             // commandBehaviour.CloseConnection will not work             try             {                 count = 0;                 PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);

                OdbcParameter _p = new OdbcParameter("@count",OdbcType.Int);                     _p.Direction = ParameterDirection.Output;                     cmd.Parameters.Add(_p);                 OdbcDataReader rdr = cmd.ExecuteReader();                 DataTable dt= gettable(rdr);                 cmd.CommandText = "select @count";                 count = int.Parse(cmd.ExecuteScalar().ToString());                 cmd.Parameters.Clear();                 return dt;             }             catch             {                 count = 0;                 conn.Close();                 throw;             }

        }

mysql c#分页通过存储过程和out参数同时获得总数和表,布布扣,bubuko.com

mysql c#分页通过存储过程和out参数同时获得总数和表

上一篇:sql数据库常用语句总结


下一篇:sql查询用nolock