views:

62

answers:

2

Hey all,

I have a web application that has a requirement to take data from an Excel workbook and load it to the database. I am using ADO.NET 2.0 and need to use DataSet/DataTable/DataAdapter/etc. to perform this task.

We also have a requirement of verifying the data before it is uploaded and informing the user if there are any PK/FK/Unique/Other constraint violations.

Currently, we are uploading the data from Excel into a DataTable and getting the data from the database into another DataTable, merging the two tables and (if everything merged successfuly) then we update the database.

Can I use methods on DataTable or DataSet (or another ADO.Net data structure) to check for PK/FK/Unique/Other constraints? What would the recommended workflow be to upload the data to the database given my requirements?

+1  A: 

Can I use methods on DataTable or DataSet (or another ADO.Net data structure) to check for PK/FK/Unique/Other constraints?

I don't think so. Instead you can start transaction and catch all the SqlException-s.

Then you could check the Number of the exception to see what kind of error it is (FK violation, Unique constraint etc)

What would the recommended workflow be to upload the data to the database given my requirements?

You may also consider using Sql Server Integration Services. It allows you to do pretty much everything.

Dmytrii Nagirniak
Sadly, we're using Sybase IQ for now ... so no SSIS :(
Jeffrey Cameron
+1  A: 

What you describe is a "standard" ETL job. Although you can do it with custom scripts, there are available tools which allow you to focus on he job itself, as opposed to custom development. There is the oracle data integrator and Pentaho suite (open source) available for download and trial.

Damir Sudarevic
Intriguing. I will examine these. Thank you!
Jeffrey Cameron