• dataset 多表查询


          string citysql = "select * from soncity;select * from partytype";
            ds= DbHelperSQL.Query(citysql);
            s1.DataSource = ds.Tables[0].DefaultView;
            s1.DataTextField = "sonname";
            s1.DataBind();
            s2.DataSource = ds.Tables[1].DefaultView;
             s2.DataTextField = "partytypename";
             s2.DataBind();

    在DbHelperSQL类中的Query方法

       /// <summary>
        /// 执行查询语句,返回DataSet
        /// </summary>
        /// <param name="SQLString">查询语句</param>
        /// <returns>DataSet</returns>
        public static DataSet Query(string SQLString)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                DataSet ds = new DataSet();
                try
                {
                    connection.Open();
                    SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);
                    command.Fill(ds, "ds");
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    throw new Exception(ex.Message);
                }
                return ds;
            }
        }

  • 相关阅读:
    题解-CmdOI2019 口头禅
    题解-NOI2003 智破连环阵
    题解-CF1282E The Cake Is a Lie
    CF1288F Red-Blue Graph
    题解-洛谷P4229 某位歌姬的故事
    莫比乌斯反演
    [HNOI2008]越狱(bzoj1008)(组合数学+正难则反)
    [FJOI2007]轮状病毒(bzoj1002)(递推+高精度)
    矩阵快速幂
    高斯消元
  • 原文地址:https://www.cnblogs.com/crazy00/p/1643949.html
Copyright © 2020-2023  润新知