Samples for use with SQL Server Integration Services samples created by the Integration Services product team. Import data from EXCEL to SQL Database in ASP. NET. ASP. NET,C#. NET,VB. NET,JQuery,Java. Script,Gridviewprotectedvoid btn. Send_Click(object sender, Event. Args e){ String str. Connection = "Data Source=My. System; Initial Catalog=My. Samples. DB; Integrated Security=True"; //file upload pathstring path = fileupload. Excel. Posted. File. File. Name; //Create connection string to Excel work bookstring excel. Connection. String = @"Provider=Microsoft. ACE. OLEDB. 1. 2. Data Source=" + path + "; Extended Properties=Excel 1. Persist Security Info=False"; //Create Connection to Excel work book. Ole. Db. Connection excel. Connection =new. Ole. Db. Connection(excel. Connection. String); //Create Ole. Db. Command to fetch data from Excel. Ole. Db. Command cmd = new. Ole. Db. Command("Select [ID],[Name],[Designation] from [Sheet. Connection); excel. Connection. Open(); Ole. Db. Data. Reader d. Reader; d. Reader = cmd. Execute. Reader(); Sql. Bulk. Copy sql. Bulk = new. Sql. Bulk. Copy(str. Connection); //Give your Destination table namesql. ![]()
Bulk. Destination. Table. Name = "Excel_table"; sql. Bulk. Write. To. Server(d. Reader); excel. Connection.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2017
Categories |