ASP.NET Connection to DB forcibly closed when importing data into table

I am using C# Visual Studio 2005 and SQL Server 2005.

Before I implemented Role Management in the ASP.NET Configuration Tool, my import of data from an Excel spreadsheets worked fine. But after I implemented Role Management, every time I tried to import data from my excel spreadsheet, the connection will be forcibly closed.

Below is a code snippet of my excel import:

string strUploadFileName = "C:/Documents and Settings/user01/My Documents/Visual Studio 2005/WebSites/MajorProject/UploadFiles/" + DateTime.Now.ToString("yyyyMMddHHmmss") + strExtension;


string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strUploadFileName + ";Extended Properties=Excel 8.0;";

using (OleDbConnection connection = new OleDbConnection(connStr))
   OleDbCommand command = new OleDbCommand("Select [COLUMNS] FROM [sheet1$]", connection);


   using (DbDataReader dr = command.ExecuteReader())
       string sqlConnectionString = "Data Source=<DS>";

       using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
          bulkCopy.DestinationTableName = "UserData";

Anyone know what might be the possible reasons? I have turned off my role management for my web application and waiting for my server to restart and I will try to import data into my table again.

Thank you in advance for any help.


You may need to close the connection when data is read. The using way can only help to dispose the object connection,but not to close it.

Wish it would help.

Need Your Help

htaccess: how redirrect to script

php apache .htaccess

How redirrect to script using htaccess

Using Primary Key / ID Field as an identifier in a URL

security database-design friendly-url

What are the pros and cons of using your databases primary key as a URL identifier? As an example, http://localhost/post/view/13 - 13 being my primary key for my posts table.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.