Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top