Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I am working with data migration..
this needs to import bulk data from excel file to respective tables in the database..
could you please help me on the easy techniqes for data validation...
data importing.. please...
Posted
Updated 9-Feb-12 19:37pm
v2
Comments
Rajesh Anuhya 10-Feb-12 1:37am    
Edited.
--RA

I am Suggesting SQLLDR.exe is the best option for you.

SQLLDR is the Oracle Utility provided by Oracle Corporation.

Follow the steps.

1. Save as your excel file as .CSV file, because sqlldr doe's not accept the Excel formats.

2. see this links for understand the Sqlldr[^]
Google[^]

3. create a control file. upload the data to the corresponding tables.

Advantages :
1. SQLLDER.exe will automatically generate a log file of the upload process.
2. SQLLDER.exe will generates a BAD file, which records is not upload Successfully.
3. It's very fast.


Thanks
--RA
 
Share this answer
 
Hi,

I thing you need this example function...
Subsequent code is pretty simple…

C#
// Open excel file, read records then return as datatable
 // Author: Algem Mojedo  
 public DataTable xlsInsert(String pth, String Schema)
 {
     string strcon = string.Empty;
     if (Path.GetExtension(pth).ToLower().Equals(".xls"))
     {
                strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
                                + pth +
                                ";Extended Properties=\"Excel 8.0;HDR=YES;\"";
     }
     else
     {
        strcon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
                  + pth +
                 ";Extended Properties=\"Excel 12.0;HDR=YES;\"";

     }
     string strselect = "Select * from [Sheet1$]";
     DataTable exDT = new DataTable();
     using (OleDbConnection excelCon = new OleDbConnection(strcon))
     {
         try
         {
            excelCon.Open();
            using (OleDbDataAdapter exDA = new OleDbDataAdapter(strselect, excelCon))
            {
                exDA.Fill(exDT);
            }
         }
         catch (OleDbException oledb)
         {
            throw new Exception(oledb.Message.ToString());
         }
         finally
         {
             excelCon.Close();
         }
         for (int i = 0; i < exDT.Rows.Count; i++)
         {
            if (exDT.Rows[i]["CARDNO"].ToString() == string.Empty)  // colummn CARDNO must not emplty
            {
                exDT.Rows[i].Delete();
            }
         }
         exDT.AcceptChanges();
         if (exDT.Rows.Count == 0)
         {
             throw new Exception("File uploaded has no record found.");
         }
         return exDT;
    }



Happy coding...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900