Data Adapter Configuration Wizard...

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

The data adapter wizard allows you to add more than one
table, but that doesn't seem to work right when setting up
a dataset. Some of the documentation I have read states
that only one table should be selected per data adapter,
and then you use a DataRelation object to pull join them
together. Okay, if that's the case then fine, but why
would the data adapter allow you to add more than one
table if this is not how it is supposed to work. If only
one table should be used, then the program should only
allow the addition of one table.

I'm sure I'm missing out on something here, but nothing I
have read explains it. I'm kinda new to vb.net, so I hope
someone can provide an explanation or reference to an
article on this.

Any help would be greatly appreciated.

Thanks,


Rick
 
Rick,
DataSet's are supposed to be able to contain one or more tables
and relations etc, that is why its called a 'Set'. I would recommend that
you dont use the wizards except for things like getting the right connection
strings and parameterised lists etc.

Spend some time looking at how the wizard places the code on the form and
then try to do this manually. You will find that you will learn a lot more
this way and also have much more control over your data.

I would suggest that you go to the adonet newsgroup for more help as there
are specialists operating there who are more likely to spend time answering
detailed questions.

Best Regards - OHM
 
Hi,


I appreciate your response, and I could not agree with you
more. I have purchased a couple of books on vb.net, and
I'm going to be doing exactly what you recommended. My
development progression is not based on using this
wizard... I am simply making a point on the principle more
than anything at this point (and in my view the question
applies to whether it's done in code or not). Again, I
appreciate your response very much and I agree with you
100% (and I will follow-up by posting the question in the
ado.net section.

Also, you made the point about a dataset containing more
than one table, but I believe the problem is based in the
adapter... not the dataset. Take the text below that I
put in from an article. Based on this text, it appears
that one adapter (whether in code or otherwise) should be
used per table, and then the dataset pulls in the multiple
tables through muliple adapters... NOT one adapter for
multiple tables.


Data adapters and Related Tables:

"An implication of having separate tables in the dataset
is that a data adapter typically does not reference SQL
Commands or stored procedures that join tables. Instead,
information from the related tables is read separately
into the dataset by different adapters. Then a
DataRelation object is used to manage constraints between
the dataset tables (such as cascading updates) and to
allow you to navigate between related master and child
records."


So again, the point is that while the above makes sense,
it does not answer the question as to why the data adapter
allows for adding multiple tables. The question is just
bothering me more than anything else... I'm not hinging me
development experience on it :o) I'm sure that writing
this in code will enlighten the issue, but it would be
nice to know what the deal is with the adapter anyway.


Thanks a lot!!
 
Hi Rick,

Makes this piece of code that I use give you the Idea that the dataadapter
can do more datasets and a datatable more datasets (I deleted some things to
make it more simple but basicly it is the same) ?

Cor
\\\
Public Shared Sub UpdateDataset(ByVal sqlStr As String, ByVal ds As DataSet,
ByVal mDatatable As String)
Dim Conn As New OleDbConnection(connString)
Try
Dim da As New OleDbDataAdapter
Dim cmd As New OleDbCommand(sqlStr, Conn)
da.SelectCommand = cmd
Dim cb As OleDbCommandBuilder = _
New OleDbCommandBuilder(da)
If ds.HasChanges Then
da.Update(ds.GetChanges, mDatatable)
End If
Catch oledbExc As OleDbException
MessageBox.Show(oledbExc.ToString)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Conn.Close()
End Try
End Sub
///
 
I think to answer you're question, I would simply turn it on its head, "Why
Not?", the approach taken was one of flexibility. One Dataset can have one
or more DataAdapters, One DataAdapter can deliver one or more tables.
Different scenario's demand different approaches.

HTH - OHM
 
Back
Top