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 7910931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:03:33+00:00 2026-06-03T13:03:33+00:00

So I have the following code to take a Excel file and write it

  • 0

So I have the following code to take a Excel file and write it to a table in my DB.

        string target = Server.MapPath("~/Upload");
        if (fupStation.HasFile)
        {
            fupStation.SaveAs(System.IO.Path.Combine(target, fupStation.FileName));

            string connectionString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", target + "\\" + fupStation.FileName); string query = String.Format("select * from [{0}$]", "Client Station Assignments");
            OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);

            DataSet dsStation = new DataSet();
            dataAdapter.Fill(dsStation);

            DataTable dtStation = new DataTable();
            dtStation = dsStation.Tables[0];

            gvOne.DataSource = dtStation;
            gvOne.DataBind();

            using (SqlBulkCopy s = new SqlBulkCopy(ConfigurationManager.ConnectionStrings["cnSQL"].ConnectionString))
            {
                s.DestinationTableName = "StationImport";
                s.NotifyAfter = 100;
                s.WriteToServer(dtStation);
                s.Close();
            }

        }

So Here is the issue. It reads the file and populate the Datatable just fine (proven by populating the Grid with it) And I know the SQLBulkCopy code is being called, but in the end it gives no errors, but nothing shows up in my table!

Anyone been thru this before? This is my first time using BulkCopy (and reading files too!) so I wouldn’t be suprized if I am doing soemthing wrong.

Thanks

  • 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-03T13:03:36+00:00Added an answer on June 3, 2026 at 1:03 pm

    Do all the columns map correctly? “the copy will not succeed if there are any mismatched columns between the two.” (source http://www.sqlteam.com/article/use-sqlbulkcopy-to-quickly-load-data-from-your-client-to-sql-server)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following code using Nhibernate.Linq var apps = Session.Linq<History>().OrderByDescending(r => r.LastUpdated).Take(50); Console.Write(apps.Count());
I have the following code to take an image and generate the thumbnail. how
I have the following code to take screenshots of a window: HDC WinDC; HDC
I have the following code to take a screenshot of a window, and get
Okay so i have a semi weridish problem with re.sub. Take the following code:
I have the following code. I would like username to take the value of
I have the following code in a project that write 's the ascii representation
I have a simple, but perplexing problem, with Math. The following code will take
I have the following code. Uri outputFileUri = Uri.fromFile( new File(path +/image01.jpg) ); camera_intent
I have the following code on the Table detail view of the table which

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.