zoukankan      html  css  js  c++  java
  • 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;
            }
        }

  • 相关阅读:
    zabbix监控系统客户端安装
    可以学习的博客地址
    Linux下Nagios的安装与配置
    ShopNC多用户商城标题去版权 后台去版权方法2.0版本
    解析crontab php自动运行的方法
    暑假周报告(第五周)
    暑假周报告(第四周)
    暑假周报告(第三周)
    暑假周报告(第二周)
    《大道至简》读后感
  • 原文地址:https://www.cnblogs.com/crazy00/p/1643949.html
Copyright © 2011-2022 走看看