Hello Dear all
I m new in C# I have project in which I want to import data From Excel to show it in Grid View and save this data in database
in Windows Form not in Asp.net
Please Help Me
Thanks in Advanced
Import Data from excel and save it in Database
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

venkata kumarRank #5,034 · 314 reputationPosted Nov 6, 2013, 9:43 PM EST
the fallowing code will be excel data you can bind to grid view.
DataTable dt = new DataTable();
SqlConnection strConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
strConnection.Open();
string filepath = textBox1.Text;
string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath + ";Extended Properties=Excel 12.0;"; //Create Connection to Excel work book
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
excelConnection.Open();
OleDbDataAdapter da = new OleDbDataAdapter("Select [ISBN/Code],[Title],[Publisher],[Author],[Qty],[Price],[Rate In INR],[Disc%],[Value In INR] from [Sheet1$]", excelConnection);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
grdInvoiceUploader.DataSource = dt.DefaultView;
}