Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Question about How to: Implement CopyToDataTable

$
0
0

Hello,

I used the coding from this How to: How to: Implement CopyToDataTable<t>Where the Generic Type T Is Not a DataRow</t>

to create a windows form program for testing.

This is the code that I created to call both CopyToDataTable methods:

namespace TestCopyToDataTable
{
    public partial class Form1 : Form
    {
        private List<MessageHeader> allMessages = new List<MessageHeader>();
        private List<MessageHeader> newMessages = new List<MessageHeader>();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            allMessages = FetchAllMessages("mail.xxxxxxxx.com", 110, false, "user@xxxxxxxx.com", "password");

            DataTable newMessageTable = CustomLINQtoDataSetMethods.CopyToDataTable(newMessages);

            DataTable messageTable = CustomLINQtoDataSetMethods.CopyToDataTable(allMessages, newMessageTable, null);
        }


The FetchAllMessages method fills the allMessages List with data.

If I stop the program right after the first call to CopyToDataTable, the newMessageTable contains the schema of MessageHeaders, but contains no rows of data.

If I stop the program right after the second call to CopyToDataTable, both the newMessageTable and the messageTable contain the schema of MessageHeaders, and both contain MessageHeader rows of data.

In trying to understand all this, I'm a bit puzzled about why the article describes "table" as "The input table".  I'm not fully understanding how a table that, is created if it does not exist, and how it can be loaded with data rows, if it is an input table.

Is the article just wrong about calling it an input table?

Any help in trying to make sense of this would be gratefully appreciated.

Thanks,
Tony


Stop The World, I want To Get Off! ........... Life Isn't About Waiting For The Storm To Pass ... It's About Learning To Dance In The Rain.






Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>