2016-10-01 4 views
0
데이터 테이블

에 내가 지금 삽입하기 전에 또는 내가 모바일 번호, 이메일 ID, 성별의 유효성을 검사 할 데이터 테이블 에 삽입 한 후 더 후 5000 검증은 여기

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(); 

의 테이블에 대량의 데이터를 걸었습니다 null 값 등

답변

0

DataTable 참조로 초기화되는 DataView 클래스를 사용하십시오. DataView에 필터 옵션을 작성합니다.

+0

를 사용한다고 생각 ???? – Aamir

0

내가 당신이 예 또는 코드로 설명 할 수이 코드

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 
         } 
        } 
       } 

      }