Going from string-> datatable, or even string->IDataReader?  
Author Message
dferraro





PostPosted: .NET Framework Data Access and Storage, Going from string-> datatable, or even string->IDataReader? Top

Hi,

I have some data that is coming into me from an Inbound TCP connection. The data is already perfectly layed out as a datatable - it is literally a pipe-delimited table, with columns and rows. Rows are deliminated by newlines, and columns delimited by pipe.

Anyway, once I have this data as an array of byte(), or one big string... How can I quickly insert this into a SQL table using the SqlBulkCopy object It seems that SqlBulkCopy.WriteToServer() only accepts either a datatable or an IDataReader....

My question is, do I really *have* to loop through my string/byte array row for row and convert this to a datatable There's no way to easily shove the string/byte array into the WriteToServer() function (or into a DataTable/IDataReader) It just seems like a shame I have to loop through the entire string row for row when it is already in a datatable-style format.

Thanks for any help.



.NET Development32  
 
 
Greg Beech





PostPosted: .NET Framework Data Access and Storage, Going from string-> datatable, or even string->IDataReader? Top

You could possibly dump the data to a file and then use OdbcDataReader to read it, though I don't know whether this would be faster and/or easier than processing it manually in memory.

 
 
Bill Lin - MSFT





PostPosted: .NET Framework Data Access and Storage, Going from string-> datatable, or even string->IDataReader? Top

You might implement an IDataReader yourself and process the byte stream yourself with appropriate getters.