Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i read data from an excel sheet from row 7 to row 11 and insert then in sql table?
Posted

C#
OleDbConnection Con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Your xcel path + ";Extended Properties=Excel 8.0");

               Con.Open();
               try
               {
                           DataSet myDataSet = new DataSet();
                   OleDbDataAdapter myCommand = new OleDbDataAdapter(" SELECT * FROM [Sheet1$]", Con);
                   myCommand.Fill(myDataSet);
                 string value=myDataSet.Tables[0].Rows[6].IttemArray[10].tostring();


                   Con.Close();


               }
               catch (Exception ex)
               {
                   MessageBox.Show("verify ur excel file");
               }
 
Share this answer
 
v2
Comments
Meena_be 2-May-13 5:43am    
thanks Perumal
KM Perumal 2-May-13 5:46am    
welcome
 
Share this answer
 
Hi,

You can use OpenXML to read excel file with .xlsx extension. Please refer : http://msdn.microsoft.com/en-us/library/office/gg575571.aspx[^]

After that you can use merge statement of SQL server to update existing records and insert new records according to Ids of records stored in excel file.

I have used it in my projects and it is good.


Thanks
 
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