Reputation: 45
I have a windows forms application to automate certain tasks and one part is to fill a SQL Server table with large amounts of information (sometime is less to 10, but i see a situation with more than 1000 lines!)
Today i have a List(of T) to execute this task. "T" is a class with 8 strings parameters.
In the "Save" function i parse the List to construct a SQL Query to insert the information in one table.
But the process of inserting in the DB sometime take several seconds to complete, even if only a few lines to insert, especially under SQL server overload. Its better to use a DataTable with the 8 string columns to store the data and use to fill the database? I appreciate other suggestions too.
best regards
Upvotes: 2
Views: 95
Reputation: 4838
On the VB side the structure used will not make a difference. If you want a faster method, you could look at the SQLBulkCopyClass to help you out.
https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy%28v=vs.110%29.aspx
Upvotes: 3