Results 1 to 5 of 5

Thread: Uploading Excel Data to Dataset, then DataSet to SQL Server

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    Uploading Excel Data to Dataset, then DataSet to SQL Server

    Hi Guys,

    What I am thinking is this? Is it possible for me to upload the data from an excel file to dataset of my application first, so that the user can view the data in a gridview to review it first, before the user strike the save button, to save it in the database. So, that in case there is a problem, the gridview will high light all the data with an error. So the user can easily pull out the excel and correct the data before saving it in the database.

    Thank you in advance.

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Uploading Excel Data to Dataset, then DataSet to SQL Server

    Hey,

    This is certainly possible.

    One thing that I would point out though is that SQL Server has a built in migration tool that will do this work for you. Have you though about using this, rather than implementing your own, or is this part of a business process that you need to meet?

    Gary

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    Re: Uploading Excel Data to Dataset, then DataSet to SQL Server

    This is part of a business process, because the users need to check the data they are trying to upload before they can save the data in the database. Do you know a tutorial that can help me to start with? Thanks

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Uploading Excel Data to Dataset, then DataSet to SQL Server

    Hey,

    Basically what you need to get to grips with is ADO.Net. There are some links in my signature that will help you there.

    Create a connection to the Excel Database, and get the information that you need. Present that to the end user, then, with another connection to the SQL Server, update/insert the rows that you need to.

    Gary

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Uploading Excel Data to Dataset, then DataSet to SQL Server

    How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET

    Pay attention to the connection string and to the special form that the queries take. You'll want to either fill up a dataset with the data from the Excel sheet or create a List(Of YourCustomClass) and fill that up. When it's time to save, loop through and run a SqlCommand.ExecuteNonQuery() for each row.

Posting Permissions

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



Click Here to Expand Forum to Full Width