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.

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
}
}
}
}
}
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/