DataSet ds = new DataSet();

SqlConnection conn = new SqlConnection(ConnectionStr);
            SqlCommand cmd = new SqlCommand();
            cmd.CommandTimeout = 180;

SqlParameter[] parameters = new SqlParameter[]{
                new SqlParameter("@strNum",SqlDbType.NVarChar,50),
                new SqlParameter("@strDjStartDate",SqlDbType.NVarChar,10),
                new SqlParameter("@strDjEndDate",SqlDbType.NVarChar,10),
                new SqlParameter("@strScStartDate",SqlDbType.NVarChar,10),
                new SqlParameter("@strScEndDate",SqlDbType.NVarChar,10),
                new SqlParameter("@strCreator",SqlDbType.NVarChar,50),
                new SqlParameter("@str_tb",SqlDbType.NVarChar,50),
               };

////1
                parameters[0].Value = strNum;
                parameters[1].Value = strDjStartDate;
                parameters[2].Value = strDjEndDate;
                parameters[3].Value = strScStartDate;
                parameters[4].Value = strScEndDate;
                parameters[5].Value = strCreator;
                parameters[6].Value = "[auto_ZYQA-P-07-06_myFields]";

try
                {
                    PrepareCommand(cmd, conn, null, CommandType.StoredProcedure, "Proc_Export8DPZYC", parameters);
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet, "t1");
                    cmd.Parameters.Clear();
                    ds.Merge(dataSet, false, MissingSchemaAction.Add);
                }
                catch
                {
                    conn.Close();
                    throw;
                }

////2
                parameters[0].Value = strNum;
                parameters[1].Value = strDjStartDate;
                parameters[2].Value = strDjEndDate;
                parameters[3].Value = strScStartDate;
                parameters[4].Value = strScEndDate;
                parameters[5].Value = strCreator;
                parameters[6].Value = "[auto_ZYQA-P-07-06_myFields_12]";
                try
                {
                    PrepareCommand(cmd, conn, null, CommandType.StoredProcedure, "Proc_Export8DPZYC", parameters);
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet, "t2");
                    cmd.Parameters.Clear();
                    ds.Tables[0].Merge(dataSet.Tables[0], false, MissingSchemaAction.Add);
                }
                catch
                {
                    conn.Close();
                    throw;
                }

////3
                parameters[0].Value = strNum;
                parameters[1].Value = strDjStartDate;
                parameters[2].Value = strDjEndDate;
                parameters[3].Value = strScStartDate;
                parameters[4].Value = strScEndDate;
                parameters[5].Value = strCreator;
                parameters[6].Value = "[auto_ZYQA-P-07-06_myFields_13]";
                try
                {
                    PrepareCommand(cmd, conn, null, CommandType.StoredProcedure, "Proc_Export8DPZYC", parameters);
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet, "t3");
                    cmd.Parameters.Clear();
                    ds.Tables[0].Merge(dataSet.Tables[0], false, MissingSchemaAction.Add);
                }
                catch
                {
                    conn.Close();
                    throw;
                }

////4
                parameters[0].Value = strNum;
                parameters[1].Value = strDjStartDate;
                parameters[2].Value = strDjEndDate;
                parameters[3].Value = strScStartDate;
                parameters[4].Value = strScEndDate;
                parameters[5].Value = strCreator;
                parameters[6].Value = "[auto_ZYQA-P-07-06_myFields_14]";
                try
                {
                    PrepareCommand(cmd, conn, null, CommandType.StoredProcedure, "Proc_Export8DPZYC", parameters);
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet, "t4");
                    cmd.Parameters.Clear();
                    ds.Tables[0].Merge(dataSet.Tables[0], false, MissingSchemaAction.Add);
                }
                catch
                {
                    conn.Close();
                    throw;
                }

////5
                parameters[0].Value = strNum;
                parameters[1].Value = strDjStartDate;
                parameters[2].Value = strDjEndDate;
                parameters[3].Value = strScStartDate;
                parameters[4].Value = strScEndDate;
                parameters[5].Value = strCreator;
                parameters[6].Value = "[auto_ZYQA-P-07-06_myFields_15]";
                try
                {
                    PrepareCommand(cmd, conn, null, CommandType.StoredProcedure, "Proc_Export8DPZYC", parameters);
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet, "t5");
                    cmd.Parameters.Clear();
                    ds.Tables[0].Merge(dataSet.Tables[0], false, MissingSchemaAction.Add);
                }
                catch
                {
                    conn.Close();
                    throw;
                }

////6
                parameters[0].Value = strNum;
                parameters[1].Value = strDjStartDate;
                parameters[2].Value = strDjEndDate;
                parameters[3].Value = strScStartDate;
                parameters[4].Value = strScEndDate;
                parameters[5].Value = strCreator;
                parameters[6].Value = "[auto_ZYQA-P-07-06_myFields_16]";
                try
                {
                    PrepareCommand(cmd, conn, null, CommandType.StoredProcedure, "Proc_Export8DPZYC", parameters);
                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet, "t6");
                    cmd.Parameters.Clear();
                    ds.Tables[0].Merge(dataSet.Tables[0], false, MissingSchemaAction.Add);
                }
                catch
                {
                    conn.Close();
                    throw;
                }

ds.Merge 与 ds.Tables[0].Merge 的用法的更多相关文章

  1. dataGridViewX和数据库的链接之dataGridViewX1.DataSource = ds.Tables[0];

    dataGridViewX1.DataSource = ds.Tables[0]; 1, dataGridViewX和数据库链接,如果我们用 dataGridViewX1.DataSource = d ...

  2. ds.Tables[0].Rows.RemoveAt(i)数据库表格删除行

    不要在循环里使用myDataTable.Rows.RemoveAt(i).因为每删除一行后.i的值会增加,但行数会是减少了.这么做一定会出错.因此要遍历数据,使用Remove方式时,要倒序的遍历int ...

  3. UICollectionView在Swift3.0中的用法

    UICollectionView在Swift3.0中的用法 UICollectionView的初始化跟OC中是相似的,创建 GameView 集成自 UICollectionView .注意不同于UI ...

  4. JS版微信6.0分享接口用法分析

    本文实例讲述了JS版微信6.0分享接口用法.分享给大家供大家参考,具体如下: 为了净化网络,整顿诱导分享及诱导关注行为,微信于2014年12月30日发布了<微信公众平台关于整顿诱导分享及诱导关注 ...

  5. Pandas中DataFrame数据合并、连接(concat、merge、join)之merge

    二.merge:通过键拼接列 类似于关系型数据库的连接方式,可以根据一个或多个键将不同的DatFrame连接起来. 该函数的典型应用场景是,针对同一个主键存在两张不同字段的表,根据主键整合到一张表里面 ...

  6. <Araxis Merge>Windows平台下的Merge概览

    它是什么 Merge是一个来自Araxis的可视化文件比较/合并及文件夹同步的应用程序. 用户界面使用英语.德语.日语.法语.国际西班牙语.汉语(繁体和简体)进行本地化了. 优势 对于软件工程师和网站 ...

  7. Vue2.0学习——axios用法详解

    功能特性 在浏览器中发送 XMLHttpRequests 请求 在 node.js 中发送 http请求 支持 Promise API 拦截请求和响应 转换请求和响应数据 自动转换 JSON 数据 客 ...

  8. UIWebView内嵌网页 Xcode7.0以后的用法

    UIWebView* webPage=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight-64)]; ...

  9. Microsoft ACE OLEDB 12.0概念及用法

    首先需要清楚几个概念: Database engine(数据引擎):一些预先存储于数据库中的组件: Microsoft JET (Joint Engine Technology):Microsoft ...

随机推荐

  1. PL/SQL Developer连接到Oracle 12c

    安装32位的Oracle客户端instantclient-basic-nt-12.1.0.1.0.zip 下载地址:http://www.oracle.com/technetwork/topics/w ...

  2. Vagrant配置与使用

    Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境.它 使用Oracle的开源VirtualBox虚拟化系统,使用 Chef创建自动化虚拟环境. Vagrant is an amaz ...

  3. Leetcode: Elimination Game

    There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number ...

  4. 网易免费邮件开启smtp教程

    网易免费邮件开启smtp教程     作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 我们在部署zabbix邮件报警中可能会用到163.com.那么我们如何去开启smtp服务呢? 1 ...

  5. HUD 5086 Revenge of Segment Tree(递推)

    http://acm.hdu.edu.cn/showproblem.php?pid=5086 题目大意: 给定一个序列,求这个序列的子序列的和,再求所有子序列总和,这些子序列是连续的.去题目给的第二组 ...

  6. CSS自定义弹出框

    <script type="text/javascript" language="javascript"> function sAlert(str) ...

  7. jQuery习题的一些总结

    1.在div元素中,包含了一个<span>元素,通过has选择器获取<div>元素中的<span>元素的语法是? 提示使用has $("div:has(s ...

  8. JSP动作跳转页面的时候与根目录的问题

    在JSP动作:<jsp:forward page="....">中,这个page属性所指定的页面要包含根目录的话,必须要用"/",不能够用" ...

  9. ls -l 列表信息详解

    我们平时用ls -l 命令查看一个目录下的文件和子目录的详悉信息时,会得到一个详细的文件和目录名列表.这个列表包含了文件的属性,所属用户,所属组,创建时间,文件大小等等信息.这些信息到底是什么意思呢? ...

  10. struts几个配置文件加载顺序_2015.01.04

    struts几个配置文件加载顺序: 01:struts-default.xml 02:struts-plugin.xml 03:struts.xml 04:struts.properties 05:w ...