Ravindra Sawant

Ravindra Sawant

  • NA
  • 34
  • 11.5k

Efficient way to validate data of DataTable

Aug 27 2013 10:46 AM
I have following DataTable (dataTable)

**ColumnName**  :   **Data**  
IDS : System.String  
QTY : System.Int32  
DOS      System.DateTime  


and following dictionary

Dictionary<string,Type> dict=new Dictionary<string, Type>();
dict["ID"]=typeof(string);
dict["QTY"]=typeof(Int32);
dict["DOS"]=typeof(DateTime);


Using following method for validating data of dataTable


public void ValidateData(Dictionary<string, Type> dict, DataTable dataTable)
{
foreach (DataRow row in dataTable.Rows)
{
// validate data here
}
}


What is best/efficient way to validate data here.

Thanks.


Answers (1)