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


Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  validate excel data before inserting to sql database - milinda nath  04-Jul-08 06:18 6:18:40 AM
      Try this - Sujit Patil  04-Jul-08 06:30 6:30:17 AM
          validate data in excel - milinda nath  04-Jul-08 07:11 7:11:14 AM
      excel validation - Partha Mandayam  04-Jul-08 06:34 6:34:20 AM
      Try these links - santhosh kumar  04-Jul-08 07:22 7:22:36 AM
      validate - sundar k  04-Jul-08 08:04 8:04:35 AM
      Re : validate excel data before inserting to sql database - Ashutosh Dhok  04-Jul-08 08:06 8:06:41 AM
View Posts