.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Post New Resource Bookmark and Share   

How to insert an excel file in oracle database using C#

Posted By:Ashutosh Jha       Posted Date: August 31, 2014    Points: 40    Category:    URL: http://www.dotnetspark.com  

How to insert an excel file in oracle database using C#

This code will show as how can we insert an excel file in oracle database using C#. Below is the code we can use for this-

Design code-

<form id="form1" runat="server">
    <asp:FileUpload id="FileUploadControl" runat="server" />
    <asp:Button runat="server" id="UploadButton" text="Upload" onclick="UploadButton_Click" />
    <br /><br />

Code Behind Page code:-

String constr = (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= '" + txtFilePath.Text + "' +;Extended Properties='Excel 12.0 XML;HDR=YES;';");
OleDbConnection con = new OleDbConnection(constr);
OleDbCommand oconn = new OleDbCommand("Select * From [Sheet1$]", con);
OleDbDataAdapter sda = new OleDbDataAdapter(oconn);
DataTable data = new DataTable();
dataGridView1.DataSource = data;

Using this code, we can insert any excel file programitically in C#. 


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend