Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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?

  • #3
    Registered User
    Join Date
    Aug 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #4
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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 explains how to connect to an excel file using ado.net.

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

  • #5
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Data Export to XLS

    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"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •