Write Unbound DGV to DB
Posted on 2013-01-02
I have code calculating and displaying results to a DataGridView which I'd like to save to database. I'm finding solutions to update results that were populated via a DataAdapter, but this data wasn't queried.
I may have as many as 1000 rows, so I'd rather not Insert line by line (VPN connection can be terrible). The only bulk method I know for SQL Server 2005 is to
INSERT INTO MyTable (Field1, Field2)
SELECT Row1Val1, Row1Val2
UNION ALL SELECT Row2Val1, Row2Val2
UNION ALL SELECT Row3Val1, Row3Val2
I don't need to check for duplicates or any validation, just shove it all into a table.