Click here to Skip to main content
Rate this: bad
good
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 22:14pm
Shibiny564
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)
        {
 
<pre>
        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);
 
        }}</pre>
 
using (SqlConnection connection = new SqlConnection(@"Data Source=pyton-exploit;Initial Catalog=SchoolManagement;User ID=AliAsadi;Password=visualc#2010@#"))
         {
 
<pre>
         connection.Open();
         using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection))
         {
 
                 bulkCopy.DestinationTableName = &quot;tblTeacher&quot;;
                 bulkCopy.WriteToServer(data);
 
                 lblSave.ForeColor = System.Drawing.Color.Green;
             }}</pre>

Load Data from excel and write "DataTable" to SQL Server Table
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

There are many more answers to your question. This one import MS Excel to datatable[^] will just solve your problem, many choices available for you.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

  Permalink  

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

  Print Answers RSS
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 395
2 Maciej Los 285
3 ProgramFOX 265
4 CHill60 200
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 395
2 Maciej Los 285
3 ProgramFOX 265
4 CHill60 200


Advertise | Privacy | Mobile
Web01 | 2.8.150331.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2015
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