Hi All,
Could you help me in my problem in working on a project that imports excel file to a datatable the validation is to catch all null values in the excel file because it will should not allow null values in the data table. Unfortunately my code dud not work. Please see my code below.
[code=c#]
for (int i = 0; i < columnNameInt.L ength -1; i++)
{
try
{
myDataTable.Col umns[columnNameIntEx portEx[i]].DefaultValue = 0;
myDataTable.Col umns[columnNameIntEx portEx[i]].AllowDBNull = false;
myDataTable.Col umns[columnNameIntEx portEx[i]].ColumnName = columnNameInt[i];
}
catch
{
MessageBox.Show (columnNameIntE xportEx[i]);
for (int j = 0; j < myDataTable.Row s.Count; j++)
{
MessageBox.Show ( "" + j);
if(Convert.IsDB Null(myDataTabl e.Rows[j][i]))
{
throw new Exception("Erro r found in row #[" + (j+1) + "]. Please check." );
}
}
}
}
[/code]
Could you help me in my problem in working on a project that imports excel file to a datatable the validation is to catch all null values in the excel file because it will should not allow null values in the data table. Unfortunately my code dud not work. Please see my code below.
[code=c#]
for (int i = 0; i < columnNameInt.L ength -1; i++)
{
try
{
myDataTable.Col umns[columnNameIntEx portEx[i]].DefaultValue = 0;
myDataTable.Col umns[columnNameIntEx portEx[i]].AllowDBNull = false;
myDataTable.Col umns[columnNameIntEx portEx[i]].ColumnName = columnNameInt[i];
}
catch
{
MessageBox.Show (columnNameIntE xportEx[i]);
for (int j = 0; j < myDataTable.Row s.Count; j++)
{
MessageBox.Show ( "" + j);
if(Convert.IsDB Null(myDataTabl e.Rows[j][i]))
{
throw new Exception("Erro r found in row #[" + (j+1) + "]. Please check." );
}
}
}
}
[/code]
Comment