Import a csv or Excel file

DenniSys

New member
Joined
Nov 22, 2009
Messages
2
Location
Tomball, TX
Programming Experience
10+
My vb.net 2008 express project is connected to a .mdf database. How do I import (copy/paste, or query) a csv file or excel data into it (preferably into or as a table)?
 
The link Hack provides above is an optimal way to import a file directly from the file to a database but sometime you need to validate data, format fields, add additional values etc before doing the import. In this case you would first need to read the data into a dataset, run your validation and formatting and then import the data from there to the database. This will also give the added benefit of being able to use transaction to roll back the entire import on all tables if for some reason any of the inserts fail.
 
Back
Top