data adaptor not available

B

bill.jenner

Since upgrading from .NET 2003 to .NET 2005, I've had a few problems
adjusting. One, I seem unable to get around is not having the
DataAdaptor available to me from the tool box. It appears I only have
DataSets and TableAdaptors available to me. In the code behind section,
I'm unable to update my information to the database simply because I
don't have the DataAdaptor.update available to me. I attempted
TableAdaptor.update() but can't seem to get the right parameters to
satisfy it. Has anyone used a method that works to update or add new
records using DataSets and TableAdaptors?
 
B

Bart Mermuys

Hi,

Since upgrading from .NET 2003 to .NET 2005, I've had a few problems
adjusting. One, I seem unable to get around is not having the
DataAdaptor available to me from the tool box. It appears I only have
DataSets and TableAdaptors available to me. In the code behind section,
I'm unable to update my information to the database simply because I
don't have the DataAdaptor.update available to me. I attempted
TableAdaptor.update() but can't seem to get the right parameters to
satisfy it. Has anyone used a method that works to update or add new
records using DataSets and TableAdaptors?

Yes.

First create a DataSource.
- Menu->Data->Show Data Sources->Add New DataSource
- Follow wizard
- You should end with one Typed-DataSet with one or more DataTable('s) and a
TableAdapter for each DataTable.

The Typed-DataSet is shown as a Data Source inside Data Sources window.
You can simple drag a DataTable onto a Form and everything will be setup on
the Form ( DataGridView, BindingNavigator, BindingSource, TableAdapter,
DataSet). In the code view you should already see all steps required to
Fill and Update using a TableAdapter.

But you can offcourse do it entirely from code:
' Suppose you have a typed DataSet with one
' DataTable named Customers:

Dim ds As New NorthwindDataSet
Dim ta As New CustomersTableAdapter

ta.Fill( ds.Customers )
ds.Customers.AddCustomersRow( "Name0", ".... " )
ds.Customers.AddCustomersRow( "Name2", ".... " )
ds.Customers.AddCustomersRow( "Name3", ".... " )
ds.Customers(0).Name = "Name1"
ta.Update( ds.Customers )

An advantage of TableAdapter's is that they can have more then one select
query unlike DataAdapters. When you select a DataSet inside Data Sources
window and click the "show in DataSet designer" button, you can visually see
and configure all DataTable's and TableAdapter's.

TableAdapter's can also support direct update, eg:
CustomerTableAdapter.Insert( "Name4", "..." )

For more information, read:
http://www.msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dnvs05/html/newdtastvs05.asp

Note that you can still use the old DataAdapter/Connection objects from the
Designer, just right click the toolbox and select "Choose Items".

HTH,
Greetings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top