语句:select rank() over(order by XXX desc) as XXX from XXX

解决方案 »

  1.   

    然后执行到DataAdapter或者DataReader时就报错
      

  2.   

    你在dataAdater前面的几行代码上面打断点调试,看看给数据库执行的语句是什么
      

  3.   

    ashx文件
    <%@ WebHandler Language="C#" Class="Handler" %>using System;
    using System.Web;
    using System.Data.OleDb;
    public class Handler : IHttpHandler {
        OleDbConnection conn = new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["OraConnection"].ToString());
        OleDbCommand cmd = new OleDbCommand();
        public void ProcessRequest(HttpContext context)
        {
            conn.Open();
            cmd.Connection = conn;
            
            OleDbTransaction odt = conn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
            cmd.Transaction = odt;
            
            context.Response.ContentType = "text/plain";
            try
            {            cmd.CommandText = "select (rank() over(order by a.sz desc)) mc from jsbxx a";
                OleDbDataAdapter daZbpx = new OleDbDataAdapter(cmd);
                System.Data.DataSet dsZbpx = new System.Data.DataSet();
                daZbpx.Fill(dsZbpx,"zbpx");                       odt.Commit();
                context.Response.Write("{");
                context.Response.Write("\"statusCode\":\"200\",\"message\":\"操作成功\",\"navTabId\":\"page3\",\"rel\":\"\",");
                context.Response.Write("\"callbackType\":\"\",\"forwardUrl\":\"\",\"confirmMsg\":\"\"");
                context.Response.Write("}");        }
            catch (OleDbException ex)
            {
                odt.Rollback();
                context.Response.Write("{");
                context.Response.Write("\"statusCode\":\"300\",\"message\":\"操作失败(" + ex.Message.ToString() + ")\",\"navTabId\":\"page3\",\"rel\":\"\",");
                context.Response.Write("\"callbackType\":\"\",\"forwardUrl\":\"\",\"confirmMsg\":\"\"");
                context.Response.Write("}");
            }    }
     
        public bool IsReusable {
            get {
                return false;
            }
        }
        protected void Page_UnLoad(object sender, EventArgs e)
        {
            try
            {
                cmd.Cancel();
                conn.Close();
                conn.Dispose();
            }
            catch { }
        }
    }
      

  4.   

    select rank() over(oder by))) mc from jsbxx a
    正确的应该是select (rank() over(order by a.sz desc)) mc from jsbxx a
      

  5.   

    这个是测试用的,不管在ORDER BY 后面加什么,都是报缺少右括号
    图来了