这是一段排序的代码,根据点击的值来重新排序。 我发现一个非常奇怪的问题。 我数据库里的game列 有各种游戏。魔兽世界,实况足球什么的。
点这些字段后都可以正常排到前面。但是 就是劲舞团不行,不知道为什么。我把劲舞团改成劲舞都能正常排序。这事可真新鲜了,一点劲舞团,就什么反应都没有protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request.QueryString["game"]))
        {
            BindGrid(Request.QueryString["game"]);
        }
        else
        {
            BindGrid(string.Empty);
        }
    }
    private void BindGrid(string game)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);        string cmd = string.Empty;
        if (string.IsNullOrEmpty(game))
        {
            cmd = "select game,sn from [order]";
        }
        else
        {
            cmd = "select game,sn from [order] where game= '" + game + "'union all select game,sn from [order] where game <> '" + game + "' ";
        }
        SqlDataAdapter sda = new SqlDataAdapter(cmd, con);
        DataSet ds = new DataSet();        con.Open();
        sda.Fill(ds);
        con.Close();        System.Text.StringBuilder str = new System.Text.StringBuilder();
        str.Append("<table border = 1>");
        str.Append("<tr>");
        for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
        {
            str.Append("<td>" + ds.Tables[0].Columns[i].ColumnName + "</td>");
        }
        str.Append("</tr>");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("<tr>");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append("<td><a href=index.aspx?game=" + ds.Tables[0].Rows[i][j].ToString() + ">" + ds.Tables[0].Rows[i][j].ToString() + "</a></td>");
            }
            str.Append("</tr>");
        }        Response.Write(str.ToString());
    }

解决方案 »

  1.   

    我用的就是本地的sql server 我就是测试一下。  发现就是“劲” 这个字排序无效。。其他中文英文都没事啊
      

  2.   


    ..................oh  my god
      

  3.   

    SQL Server有多种中文排序方法,例如:Chinese、Chinese_PRC、Chinese_PRC_CS_AS_KS_WS、Chinese_PRC_CI_AI_KI_WI 等,你使用哪一种?你使用的“本地的sql server”是简体中文版、繁体中文版,还是英文版?
      

  4.   

    参考一下:http://www.google.cn/search?q=sql+server+%E5%AD%97%E7%AC%A6%E9%9B%86&complete=1&hl=zh-CN&newwindow=1&rlz=1T4GGIJ_zh-CNCN277CN277&sa=2
      

  5.   


    我用的是本地的sql server”是简体中文版