(C #) Excel data import into SQL Server

Source: Internet
Author: User
excel|server|sqlserver| Data Writing program, put the appendix of the Excel file (experimental questions Annex 1) class 03 student list. xls
or (appendix 2 of the Experiment) the performance registration form. xls) is imported into the SQL SERVER2000 database.
Requirements:
1. Excel file as data source
2, according to the Excel file fields in SQL Server to establish the corresponding fields
3, the record in the execl to the SQL Server


String Strcon = "Provider = microsoft.jet.oledb.4.0;" Data Source = C:\\test.xls; Extended Properties=excel 8.0 ";
OleDbConnection myconn = new OleDbConnection (Strcon);
MyConn.Open ();
String strcom = "Select Category,comp_num from [sheet1$]";
OleDbDataAdapter mycommand = new OleDbDataAdapter (strcom,myconn);
DataSet1 = new DataSet ();
Mycommand.fill (DataSet1, "[sheet1$]");
Myconn.close ();


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.