Is it possible to add Queue Data to DataTable in C#? -


i adding items in queue"<"string">" asynchronously queue.instead of inserting row row each data of queue using insert query, want add these items datatableonly when if(evtlogqueue.count==1000). datatable used further bulk insert using bulkcopy sqlserverdb.

i know possible do? if yes how? or other suggestion?

sample code:

static queue<string> evtlogqueue = new queue<string>(); public static void additemstoqueue(string itm) { evtlogqueue.enqueue(itm); console.writeline("length of queue:" + evtlogqueue.count); } 

yes possible , can adding code additemstoqueue(string itm) method.

public static void additemstoqueue(string itm) { evtlogqueue.enqueue(itm); // add following code if (evtlogqueue.count == 1000) { datatable datatable = new datatable(); datatable.columns.add("log"); foreach (var log in evtlogqueue) { datarow dr = datatable.newrow(); dr["log"] = log; datatable.rows.add(dr); } evtlogqueue.clear(); // need clear queue. sendbulkdata(datatable); // send bulk data } } 

Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -