Click here to Skip to main content
12,255,255 members (30,169 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# .NET
import excel dsta to databse ,I use the code in link:


http://www.dotnetspider.com/resources/42912-Read-Excel-Data-Show-GridView-asp-net.aspx[^]


but here there is no connection code and table specification .I think it is in webconfig.How to do this .
Any one please help me.
Posted 22-Aug-12 21:14pm
Shibiny580
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Perhaps this article would help
SQL Import Data from Excel[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 6

DataTable data = new DataTable();
 string ExtraConnection = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + openExcelFile.FileName + ";Extended Properties=\"Excel 8.0;IMEX=1;HDR=" + "YES" + "\"");
private void InsertToDataTable(string ExtraConnection)
     {
 
         using (OleDbConnection connection = new OleDbConnection(@ExtraConnection))
         {
 
             OleDbCommand command = new OleDbCommand("SELECT * FROM " + txtSheet.Text, connection);
             command.CommandTimeout = 20;
             connection.Open();
             OleDbDataAdapter SDA = new OleDbDataAdapter(command);
             OleDbCommandBuilder SCB = new OleDbCommandBuilder(SDA);
             DataSet m_DataSet = new DataSet();
             SDA.Fill(m_DataSet);
             connection.Close();
             foreach (DataTable table in m_DataSet.Tables)
                 foreach (DataRow row in table.Rows)
                     data.Rows.Add(row.ItemArray);
 

         }}
using (SqlConnection connection = new SqlConnection(@"Data Source=pyton-exploit;Initial Catalog=SchoolManagement;User ID=AliAsadi;Password=visualc#2010@#"))
         {
 
             connection.Open();
             using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection))
             {
                 
                     bulkCopy.DestinationTableName = "tblTeacher";
                     bulkCopy.WriteToServer(data);
                     
                     lblSave.ForeColor = System.Drawing.Color.Green;
                 }}


Load Data from excel and write "DataTable" to SQL Server Table
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 27 May 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100