Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2004, 05:35 AM
Registered User
 
Join Date: Oct 2003
Location: , , United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Quickest way to write data to Access DB in VB.NET

I use VB.NET/ADO.NET to access an Access database and I need a very quick way of inserting loads of rows into one table in the database.
There seems to be so many different combinations/solutions but I need the quickest one!
My VB.NET book seems to give many code examples on how to retreive data, but what is the best way to insert data?
Really appreciate some ideas or code samples.

Anne

Reply With Quote
  #2 (permalink)  
Old August 18th, 2004, 09:53 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi aslyon,
   Your Data should be store in a DataSet(ds) and DataTable(dt), just Set your data adapter. your data adapter should contain the parameter and query.

da.insertcommand.connection = con
ds.update(dt)



~ Human Knowledge Belongs to the World !
Reply With Quote
  #3 (permalink)  
Old September 21st, 2004, 10:16 AM
Authorized User
 
Join Date: Aug 2004
Location: Ottawa, Ontario, Canada.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried to do the update to a data adapter and have even followed the Microsoft book and it just doesn't work.

I keep getting an error that no value is given for one or more parameters....

But when I add a row to the data set with new data it asks me for an Insert command!

This is one of the most frustrating things going. VB6 was so much easier.


Guy
Reply With Quote
  #4 (permalink)  
Old September 21st, 2004, 10:51 AM
Registered User
 
Join Date: Oct 2003
Location: , , United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You have to tell the data adapter how to insert your data! You give it a Select statement when you create it, but it is not clever enough to figure out the Update/Insert/Delete statements. Either you have to code it manually (myDA.InsertCommand = ...) or you can use a CommandBuilder:
Dim myCB as New oledb.oleDBCommandBuilder(myDA)
which automatically creates Update & Insert statements based on your Select statement.

Anne

Reply With Quote
  #5 (permalink)  
Old September 22nd, 2004, 08:00 AM
Authorized User
 
Join Date: Aug 2004
Location: Ottawa, Ontario, Canada.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Anne, that clears things up a bit.

I did try the technique that you mentioned but to no avail....I guess it is a problem between the chair and the screen right now...grrr

Oh well back to the grind stone

Guy

Guy
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net - Access DB - Date compare johneecc VB How-To 4 August 7th, 2008 04:23 PM
How to connect to Access db thru VB.NET? am_kuthus Visual Studio 2008 1 June 3rd, 2008 04:48 AM
Connecting to Access 20007 DB with vb.net JohnBoy VB.NET 1 May 21st, 2008 01:26 PM
New in .Net VB but learning datareader, access DB tjgrindsted ASP.NET 2.0 Basics 2 February 6th, 2007 08:49 PM
Quickest way to generate data from 1 db to another flyin ADO.NET 7 August 13th, 2004 10:18 AM



All times are GMT -4. The time now is 06:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.