2016-10-01 10 views
0

にここで私は5000 +今私は携帯電話番号、電子メールIDの検証をチェックしたい挿入する前に、またはデータテーブル の挿入後の検証は、データテーブル

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

      } 
関連する問題