2016-10-01 1 views
0

hier bin Putting ich ein Massendaten in der Tabelle von mehr als 5000+Validierung in der Datentabelle

using (OleDbConnection excel_con = new OleDbConnection(conString)) 
     { 
      excel_con.Open(); 
      string sheet1 = excel_con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null).Rows[0]["TABLE_NAME"].ToString(); 
      DataTable dtExcelData = new DataTable(); 





      dtExcelData.Columns.AddRange(new DataColumn[10] { 

//this are my columns of records 

      new DataColumn("Employee Code",typeof(string)), 
      new DataColumn("Employee Type", typeof(int)), 
      new DataColumn("First Name", typeof(string)), 
      new DataColumn("Last Name", typeof(string)), 
      new DataColumn("Gender",typeof(string)), 
      new DataColumn("Email ID", typeof(string)), 
      new DataColumn("Mobile No#", typeof(string)), 
      new DataColumn("Current Address", typeof(string)), 
      new DataColumn("Permanent Address", typeof(string)), 
      new DataColumn("Status",typeof(string)) 
     } 
      ); 


      using (OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM [" + sheet1 + "]", excel_con)) 
      { 
       oda.Fill(dtExcelData); 


      } 
      excel_con.Close(); 

jetzt vor dem Einsetzen oder nach Einsatz in Datentabelle ich will keine Validierung von Mobil überprüfen, E-Mail-ID, Geschlecht, Nullwert usw.

Antwort

0

Verwenden Sie die DataView-Klasse, die mit Verweis auf DataTable initialisiert wird. Schreiben von Filteroptionen in DataView.

+0

Können Sie mit Beispiel oder Code erklären ???? – Aamir

0

Ich glaube, Sie diesen Code verwenden sollten

using (OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM [" + sheet1 + "]", excel_con)) 
      { 
       oda.Fill(dtExcelData); 
       if(dtExcelData.rows.count<0) 
       { 
       for(int i=0;i<dtExcelData.rows.count;i++) 
       { 
        string mobno=dtExcelData.rows[i]["Mobile No#"].tostring(); 
        if(mobno=="") 
        { 
         //code here 
         } 
        } 
       } 

      } 
Verwandte Themen