Results 1 to 5 of 5

Thread: Appending database @ runtime

  1. #1

    Thread Starter
    Lively Member sk8er_boi's Avatar
    Join Date
    Jun 2010
    Posts
    65

    Question Appending database @ runtime

    hey all,

    here's the thing my colleague needs to append a database from a excel file (having same structure/headers). For eg. if i already have a database with following fields :

    Name, EMP_ID, City, Position

    along with some data already in it & let's say i need to add new data every week/month , is there any way i can do this @ run time using VB 2005?

    Let's say i format my excel sheet similar to db structure & place it @ a common location & then with a click of a button Vb would import the excel sheet data into my databse...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Appending database @ runtime

    You can use ADO.NET to read the Excel file into a DataTable, almost exactly the same way as would read an Access database. You might then use a DataAdapter to save the whole DataTable to your database, or use the SqlBulkCopy class if you're using SQL Server.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member sk8er_boi's Avatar
    Join Date
    Jun 2010
    Posts
    65

    Re: Appending database @ runtime

    Quote Originally Posted by jmcilhinney View Post
    You can use ADO.NET to read the Excel file into a DataTable, almost exactly the same way as would read an Access database. You might then use a DataAdapter to save the whole DataTable to your database, or use the SqlBulkCopy class if you're using SQL Server.
    could you paste a sample code... pls pls pls... i'm literally blank when it comes to db coding

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Appending database @ runtime

    You know there's a whole world wide web out there, right? If examples are what you want then I'm quite sure you can find some quite easily. I think what you're really asking for is for someone to do it for you, which I don't find conducive to learning. The searching, finding, trying and failing are all part of the learning, as far as I'm concerned. If what you want is to learn then that's what you should do.

    I'd suggest starting by following the Database FAQ link in my signature to check out some of our own ADO.NET resources. One of those is a CodeBank thread of my own that provides code examples. It also provides a link to a site that has many different connection string formats, including for Excel.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member sk8er_boi's Avatar
    Join Date
    Jun 2010
    Posts
    65

    Re: Appending database @ runtime

    Quote Originally Posted by jmcilhinney View Post
    You know there's a whole world wide web out there, right? If examples are what you want then I'm quite sure you can find some quite easily. I think what you're really asking for is for someone to do it for you, which I don't find conducive to learning. The searching, finding, trying and failing are all part of the learning, as far as I'm concerned. If what you want is to learn then that's what you should do.

    I'd suggest starting by following the Database FAQ link in my signature to check out some of our own ADO.NET resources. One of those is a CodeBank thread of my own that provides code examples. It also provides a link to a site that has many different connection string formats, including for Excel.
    guess i was just been lazzzy... i'll do it , thx for explaining the logic

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