DataAdapter fills wrong table?

A

al

Greetings,

I have an app. One MDI parent(main),one dataset,two MDI childs,
Employees and Custoemrs,respectivly. User starts app, cliks button
to show Employees form and dataadapter(DA) then fills dataset from
Select * from employee. Then user clicks another button to show the
Customers Form and DA fills the same dataset from Select * from
customers. The problem is when the user tries to refresh the first
form, Employees form in this case, an error occurs saying mismatch
happens betweeen dataset tables then shows some fields from customers
table in Employees form. The tables I use are ActiveMdiChild.Text
property which is passed to the dataadapter.fill method.


Case Refresh
If ActiveMdiChild is ActiveMdiChild Then
DatasetNorthwind.Tables(ActiveMdiChild.Text).Clear()
DataadapterNorthwind.Fill(DatasetNorthwind,ActiveControl.Text)
End If
End Case

It seems to me that DA fills the last used table, no matter what.
Help please.

MTIA,
Grawsha
 
M

Miha Markic

Hi al,

It should be better if you were using two dataadapters - for one table one
adapter.
Anyway, did you notice that you are using different controls
(ActiveMdiChild, ActiveControl.Text) in your method?
And what is the meaning of
If ActiveMdiChild is ActiveMdiChild Then?
 
A

al

Miha Markic said:
Hi al,

It should be better if you were using two dataadapters - for one table one
adapter.
Anyway, did you notice that you are using different controls
(ActiveMdiChild, ActiveControl.Text) in your method?
And what is the meaning of
If ActiveMdiChild is ActiveMdiChild Then?

Miha,
Thanks for your help.
It should be better if you were using two dataadapters - for one table one
adapter.
But if I have the same connection(to one db) and even the same SQL
statement (but different tables), will it be better to just pass those
to a global DA in class module?
Anyway, did you notice that you are using different controls
(ActiveMdiChild, ActiveControl.Text) in your method?
Sorry, that was a typo.
And what is the meaning of
If ActiveMdiChild is ActiveMdiChild Then?
Refresh case is the same for all mdi child form. And Since i'm dealing
with MDI app, I will always have one ACTIVE Mdi Child. just a way to
have .net excute this refresh case.
 
K

Kathleen Dollard

Al,

What overload of Fill are you using? You can pass the explicit DataTable you
want filled if you like and side step these issues.

Kathleen
 

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