Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 18th, 2004, 05:35 AM
Registered User
 
Join Date: Oct 2003
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

 
Old August 18th, 2004, 09:53 PM
Authorized User
 
Join Date: Aug 2004
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 !
 
Old September 21st, 2004, 10:16 AM
Authorized User
 
Join Date: Aug 2004
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
 
Old September 21st, 2004, 10:51 AM
Registered User
 
Join Date: Oct 2003
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

 
Old September 22nd, 2004, 08:00 AM
Authorized User
 
Join Date: Aug 2004
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





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





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