Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8272713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:13:21+00:00 2026-06-08T07:13:21+00:00

i have excel file with several columns and i was able import it to

  • 0

i have excel file with several columns and i was able import it to my DataGridView in C# Win Forms so user can see and edit the data..
the problem is: how to store the data in the DataGridView to the sql server which stores only available Column on the Database..
this is the quick illustration..

database

excel

this my current codes..

    private void buttonImport_Click(object sender, EventArgs e)
    {
        if (openFileDialogExcel.FileName != "Excel File")
        {
            try
            {
                System.Data.OleDb.OleDbConnection MyConnection;
                System.Data.DataSet DtSet;
                System.Data.OleDb.OleDbDataAdapter MyCommand;
                MyConnection = new System.Data.OleDb.OleDbConnection(@"provider=Microsoft.Jet.OLEDB.4.0;Data Source='"
                + openFileDialogExcel.FileName + "';Extended Properties=Excel 8.0;");
                MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Data$]", MyConnection);
                MyCommand.TableMappings.Add("Table", "Student");
                DtSet = new System.Data.DataSet();
                MyCommand.Fill(DtSet);
                dataGridView1.DataSource = DtSet.Tables[0];

                MyConnection.Close();
            }
            catch (Exception Fail)
            {
                MessageBox.Show(Fail.ToString());
            }
        }
        else
        {
            MessageBox.Show("Browse 1st");
        }
    }

And i have 1 button for saving the data exclude “Gender” Columns..

private void buttonSave_Click(object sender, EventArgs e)
{
    -----BLANK :(

}

Thanks in Advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:13:23+00:00Added an answer on June 8, 2026 at 7:13 am

    If you want to just INSERT these data on the server the most optimum way would be to use Bulk operation…

            using (SqlConnection cn = new SqlConnection(YourConnectionString))
            {
                cn.Open();
                using (SqlBulkCopy bulkCopy = new SqlBulkCopy(cn))
                {
                    bulkCopy.DestinationTableName = "dbo.Student";
    
                    try
                    {
                        bulkCopy.ColumnMappings.Add("StudentID", "StudentID");
                        bulkCopy.ColumnMappings.Add("Name", "Name");
                        bulkCopy.ColumnMappings.Add("Address", "Address");
    
                        // Bulk write on the server
                        bulkCopy.WriteToServer(DtSet.Tables[0]);
    
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several excel files carrying 90 columns and about 500 rows, each file
I have an Excel file that I need to import into a (new) Oracle
I have an Excel file that gets external data from database table. I need
I have an excel file which is refreshing data every few seconds and running
I have a Excel File, i am able to read single row from Excel
I have an Excel file which contains some data in a 2d array. What
I have an Excel file with a lot of data in it . i
I have excel file with following columns Field1 Field2 Field3, Field4 =============================== 123 4
I have an Excel file (which has data imported from Oracle 10G Database) one
I have an excel file(VSTO), which will be uploaded with data. However I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.