如何从现有表将数据填充到临时表中 [英] How To fill Data into temporary table from existing table

查看:65
本文介绍了如何从现有表将数据填充到临时表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我已经通过编程创建了一个临时表.我想将该临时表的数据显示在asp.net的网格视图中.我希望这个临时表将显示现有表的数据中的数据.如何填充前端现有表中的临时表.

临时表的编码是:---

Hello All,
I have created a temporary table through programming.I want to show data of this temporary table into grid view in asp.net.I want that this temporary table will show data from existing table''s data.how it will be possible to fill temporary table from existing table in front end.

coding for Temporary table is:---

private DataTable CreateDataTable()
    {
        DataTable myDataTable = new DataTable();

        DataColumn myDataColumn;

        myDataColumn = new DataColumn();
        myDataColumn.DataType = Type.GetType("System.Int32");
        myDataColumn.ColumnName = "id";
        myDataTable.Columns.Add(myDataColumn);

        myDataColumn = new DataColumn();
        myDataColumn.DataType = Type.GetType("System.String");
        myDataColumn.ColumnName = "Req_Name";
        myDataTable.Columns.Add(myDataColumn);

        myDataColumn = new DataColumn();
        myDataColumn.DataType = Type.GetType("System.Int32");
        myDataColumn.ColumnName = "Req_Amt";
        myDataTable.Columns.Add(myDataColumn);

        myDataColumn = new DataColumn();
        myDataColumn.DataType = Type.GetType("System.DateTime");
        myDataColumn.ColumnName = "Req_date";
        myDataTable.Columns.Add(myDataColumn);

          myDataColumn = new DataColumn();
          myDataColumn.DataType = Type.GetType("System.Int32");
        myDataColumn.ColumnName = "Req_head_ID";
        myDataTable.Columns.Add(myDataColumn);

          myDataColumn = new DataColumn();
          myDataColumn.DataType = Type.GetType("System.Int32");
        myDataColumn.ColumnName = "Req_lib_head_id";
        myDataTable.Columns.Add(myDataColumn);

          myDataColumn = new DataColumn();
        myDataColumn.DataType = Type.GetType("System.String");
        myDataColumn.ColumnName = "req_quantity";
        myDataTable.Columns.Add(myDataColumn);
         

        return myDataTable;
    }

推荐答案

尝试一下. 首先,您必须使用适当的SQL填充数据表,然后将该数据表的每一行复制到临时表中.
Try this.. I have the same situation and i solved by this.
First you have to fill a datatable using appropriate SQL and then copy each row of this datatable to your temp table.


这篇关于如何从现有表将数据填充到临时表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆