Re : validate excel data before inserting to sql database |
| Ashutosh Dhok replied to milinda nath at 04-Jul-08 08:06 |
Hi Milinda,
After filling "dt" table from Excel sheet, use two for loop. One for rows and other for Columns.And then check the value in the field. If all the value is ok then, create new table and insert these row in it.
The new table will be the rows which are all validated value. And then insert the value frrom new table to SQL table.
in Else of your Code:
Dim newdt as datatable Dim dr1 as datarow
Add no of columns in new Tabel "newdt" as present in table from excel for int i=0;i<dt.rows.count;i++) { for(int i=0;i<dt.rows.count;i++) { . . . Here is your check code. If all values of Row is ok set some flag. ] Check this flag here. if flag is true dr1 = newdt.NewRow(); assgin value to dr1 from dt.row(i) add row to "newdt" Table newdt.Rows.Add(dr1); } Use this newdt Table for your further process.
Regards
Ashutosh |
|