Datatable validations

Posted by Hanu412 under C# on 11/23/2013 | Points: 10 | Views : 617 | Status : [Member] | Replies : 1
I have a datatable which is being filled with the data that is read via an excel sheet. This datatable has to be validated. It contains 34 columns of varying data types like char,datetime,string,int etc.

Conditions for validation ::
1.Of these 34,12 columns should not be null.
2. These 12 columns have fixed datatypes. (ex: col 1 must be char,col 3 must be string etc)
3. If each row passes the above two validations,the entire row should be added to a new datatable2.
4. If either 1 or 2 fails,that row should be added to a new datatable3.

For those who want to try this,please try it for a table with 10 columns and take mandatory columns as 4 instead of 12. Select your own datatype for each of the column.


Posted by: Learningtorise on: 11/25/2013 [Member] Starter | Points: 25

Simple Approach(If you r using SQL):

Upload your data from Excel and then insert it in SQL table.
Perform all your validation there
If it results to false, Show reason to User, Else do whatever u want to do with that Table.

Hanu412, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response