|
-
Aug 4th, 2010, 04:16 AM
#1
Thread Starter
Lively Member
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...
-
Aug 4th, 2010, 04:46 AM
#2
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.
-
Aug 4th, 2010, 07:47 AM
#3
Thread Starter
Lively Member
Re: Appending database @ runtime
 Originally Posted by jmcilhinney
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
-
Aug 4th, 2010, 07:53 AM
#4
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.
-
Aug 5th, 2010, 03:29 AM
#5
Thread Starter
Lively Member
Re: Appending database @ runtime
 Originally Posted by jmcilhinney
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|