Helpful Information
 
 
Category: ASP.NET
Upload .xls file to SQL Server

I got so far as to take a file from my local machine to another directory on my C: drive:

Dim getmyFile As HttpPostedFile = myfile.PostedFile
If IsNothing(getmyFile) Then
Label2.Text = "Please select a file to upload"
Label2.Text = "Line 78"
Else
If getmyFile.ContentLength = 0 Then
Label2.Text = "Cannot upload zero length file"
Else
Dim ServerFileName As String = Path.GetFileName(myfile.PostedFile.FileName)
getmyFile.SaveAs("C:\TestSaving\" & ServerFileName)
Label2.Text = "Successful upload to C:\TestSaving\" & ServerFileName
End If
End If

...............now, what I need to do is take an .xls file and allow users to upload that into a specific table.
Any suggestions or samples/articles are more than welcome!

Thanks!

http://www.codeproject.com/aspnet/fileupload.asp is an article on uploading and saving info to database. Is that what you were looking for? or do you want to save the entire .xls file in a database table?

miranda,

Thanks for the reply!

I just want to take whatever rows are in the sheet, and append them to an existing table. So, for instance, if the sheet1 in the .xls file has 15 rows/records, and the table on the DB server has 10, once the user uploaded the .xls file's data, the DB server's table would now have 25 records.

Thanks!

ok, so then basically what you want to do is upload the .xls file, connect to it, read the information and insert it into the database table.

This Microsoft KB article (http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311731) explains how to connect to an excel file using ado.net.

All you have left after that is inserting the rows into the database.

Your issue looks interesting. There is a component named Spire.DataExport, if you want to export data from database to Excel(many formats are supported, such as PDF,Word,HTML and so on), you may choose it, it's very fast and stable when you export data from database. And now, it's free for everyone. You may visit here for further information:
http://www.codeproject.com/KB/cs/Excel_PDF_Word_ExportWiz.aspx"










privacy (GDPR)