OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source= c:/file.xls; Extended Properties=Excel 8.0; "); OleDbDataAdapter oadp1 = new OleDbDataAdapter("Select * from [sheet1$] where Id >0", con); DataSet ods1 = new DataSet(); oadp1.Fill(ods1, "Data"); DataSet Dds1 = new DataSet(); Dds1.Tables.Add(new DataTable("NewData")); Dds1.Tables[“NewData”].Columns.Add(new DataColumn("Id")); Dds1.Tables[“NewData”].Columns.Add(new DataColumn("Name")); for (int i = 0; i < ods1.Tables[“Data”].Rows.Count; i++) { DataRow row = Dds1.Tables[“NewData”].NewRow(); row[0] = ods1.Tables[“Data”].Rows[i][0]; row[1] = ods1.Tables[“Data”].Rows[i][1]; Dds1.Tables[“NewData”].Rows.Add(row); } SqlConnection con1 = new SqlConnection(“Password = 123; Persist Security Info = True; User ID = sa; Initial Catalog = DB; Data Source = .;”); SqlDataAdapter adp = new SqlDataAdapter("select * from CompanyData", con1); SqlCommandBuilder scb = new SqlCommandBuilder(adp); adp.InsertCommand = scb.GetInsertCommand(true); adp.Update(Dds1, "CompanyData");
Search You Want
Monthwise Posts
Search Under Category
Posts’ Tags
.Net (223) ADO.NET (10) Air Conditioner (16) Asp.Net (137) Body-Weight (9) C# (39) C Programming Language (23) Data Structure (36) Design Pattern (20) Digital Currency (9) Eating & Drinking (55) Exam 70-511 - TS: Windows Applications Development with Microsoft .NET Framework 4 (18) Exam 70-536 - TS: Microsoft .NET Framework - Application Development Foundation (15) Exam 70-562 - TS: Microsoft .NET Framework 3.5, ASP.NET Application Development (35) Fever (16) Finance (47) Funds (58) General Knowledge (128) GST (11) Insurance (25) Internet Information Services (IIS) (13) Interview Questions and Answers (471) Investment (21) JavaScript (19) Job (60) LINQ (Language Integrated Query) (56) MCPD Web Developer 4.0 Certification (35) Mental Health (13) MVC (156) OOPs (73) Pain (13) PPF (22) Shares (21) Silverlight (12) Skin (22) Software Development Methodology (12) Software Testing (32) SQL (113) TAX (25) TDS (12) Trading (16) Treatment (14) Web-Service (10) Windows Azure (11) Windows Communication Foundation (WCF) (49)