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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:47:58+00:00 2026-05-26T12:47:58+00:00

I am doing an import of data from excel spreadsheet to SQLServer 2005 via

  • 0

I am doing an import of data from excel spreadsheet to SQLServer 2005 via C# Visual Studio 2005. I guess my connection was up as I receive no errors till the very last part whereby my credentials for my username and password for sqlconnectionstring was prompted as invalid. Below is the error code and my code.

enter image description here
https://i.stack.imgur.com/MjRXm.png

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Data.OleDb;
using System.Data.Common;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    public static string path = @"c:\Documents and Settings\rhlim\My Documents\Visual Studio 2005\WebSites\insqlserver\studentsheet1.xls";
    public static string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=Excel 8.0;";

    protected void Page_Load(object sender, EventArgs e)
    {
        // Connection String to Excel Workbook
        //**string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\Documents and Settings\rhlim\My Documents\Visual Studio 2005\WebSites\insqlserver\studentsheet.xls';Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";


        // Create Connection to Excel Workbook
using (OleDbConnection connection =
             new OleDbConnection(connStr))
{
    OleDbCommand command = new OleDbCommand
            ("Select StudentName,RollNo,Course FROM [Sheet1$]", connection);

    connection.Open();

    // Create DbDataReader to Data Worksheet
    using (DbDataReader dr = command.ExecuteReader())
    {
        // SQL Server Connection String
        string sqlConnectionString = "Data Source=<IP>;Initial Catalog=<database>;User ID=<userid>;Password=<password>;Integrated Security=True";

        // Bulk Copy to SQL Server
        using (SqlBulkCopy bulkCopy =
                   new SqlBulkCopy(sqlConnectionString))
        {
            bulkCopy.DestinationTableName = "ExcelData";
            bulkCopy.WriteToServer(dr); <------Error appeared at this line
        }
    }
}
}
}
  • 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-05-26T12:47:59+00:00Added an answer on May 26, 2026 at 12:47 pm

    remove the “integrated security” part from your db connectionstring. This is setting your connection to use the windows authentication instead of the sql authentication. Look for examples on http://www.connectionstrings.com/

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

Sidebar

Related Questions

I am copying data from a table created by an Excel spreadsheet import. Here
I need to import data from *.dmp file say mydump.dmp. What I'm doing is:
I will be doing an occiasional import from XML into core data. I have
I want to import data from an Excel file - assume Excel 2003 /
I am doing something like this in myproject.myapp.urls : from django.conf.urls.defaults import * urlpatterns
I'm working on a C++ application to read some data from an Excel file.
I'm importing data in a SQL Server 2008 database from excel file where the
For part of a web application the user needs to import some data from
I have a requirement to take the test data from Excel sheet and write
I'm doing a one-time import routine from one system to another. The first step

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.