Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate Data from a dataset

Status
Not open for further replies.

Kalisto

Programmer
Joined
Feb 18, 2003
Messages
997
Location
GB
Hi, I have a dataset (from an excel file).
I need to validate this, as I cant trust that the excel spreadsheet will comply with all the rules that my customer has stated.

I can easily import a spreadsheet to a dataset, but now I need to validate it. I was hoping to use the Column_Changing event, but it seems that when the dataset is loaded, this doesnt count asa column change event, and so nothing is fired.

should the column_changing event be firing when I do dataAdapter.fill(ds)?, or do I need to then go through the ds manually, and check each row / column against the validation rules I have?

Any better ways of validating data from a spreadsheet?

Cheers

K
 
I'd validate the DataSet once it has been fully loaded (by looping through it). You could set up a validation class where you pass the DataSet into the relevant method and return a status. This way it means that the validation method is re-usable if you ever come across the need to validate the data from another page or application.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
So your saying Im trying to be too clever?

It turns out that although the column changed avent doesnt fire, the row changed event does, so I can parse all the data on the way in. However your argument for a specific class that I can re-use is also a good one :)

Cheers

K
 
It's not really being too clever, but I think the benefit of it being re-usable could make it a better alternative. Plus, the row changed event will fire for each row whereas if you put the method into a class, you can return an "invalid data" status as soon as you get an invalid row. You can then stop processing any further rows and save a bit of time/processing power.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top