Last post Aug 27, 2009 04:51 PM by RamchanderP
Aug 21, 2009 11:35 PM|akpuk|LINK
One of the requirements I have for the .net web application I am developing is to give end users the ability to upload data from an Excel spreadsheet to a SQL Server database. In other words, an end use presses a button, specifies the location of an Excel
file on there local machine and then loads the data in the Excel document into a SQL server table.
Do you have any recommendations about how this can be implemented? Please note that I am not interested in displaying this data on a web page.
Aug 22, 2009 01:48 AM|vik20000in|LINK
use SQL BulkCopy. Here is a good example
Aug 22, 2009 04:54 PM|akpuk|LINK
Thanks for that.
The sample code works fine. One point I had regarding the sample is that the Excel spreadsheet is located in the App_Data folder on the web server. If the client specifies a file (using the FileUpload control) do I need to save the file to the web server
before it can be loaded or can I load it straight from the client machine.
In my code I save the file to the web server and then load. i.e.
string filePath = Server.MapPath("App_Data") + "\\" + this.FileUpload1.FileName;
string file = this.FileUpload1.FileName;
Is this necessary?
Aug 27, 2009 11:24 AM|Forward Sun - MSFT|LINK
In your case, we need to upload client Excel spreadsheets to your Web server and read it after saving it.
Aug 27, 2009 11:35 AM|suthish nair|LINK
Import Excel Spreadsheet Data into SQL Server Database Table Using SqlBulkCopy
Aug 27, 2009 04:16 PM|akpuk|LINK
So basically the process is as follows:
a) Copy Excel spreadsheet from the client machine to the web server.
b) Use SQL Bulk Copy to load the data in
If this is the case, then I would like to delete the spreadsheet from the web server after the data is loaded int. How can I do this?
Aug 27, 2009 04:33 PM|suthish nair|LINK
Aug 27, 2009 04:51 PM|RamchanderP|LINK
try this link