Why changing datasets shows fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'll try this one again now that I have my registration in order

combobox shows fields only when I change datasets

This is the first time the problem has arisen

For the table - Authors - I want updated, inserted, selected - and for the four comboboxes I created separate dataadapters and put all the tables into one dataset

daAuthorsTw
daAuthorTypeTw
daPrimaryPubTw
daPointOfViewTw
daPermissionsTw

dsAuthorsTwo, instantiated as dsAuthorsTwo1

All the four textboxes, the checkbox and two of the four comboboxes showed their column values

I tried various fixes. Finally I created another dataset from daAuthorsTwo, named dsAuthors3 and instantiated as dsAuthors31. It contained only the authors table

I redid the databindings for all the controls, selecting dsAuthors31. All the fields filled

Can somebody inform me what I did wrong? It's not that I'm new at this. I take my template from ADO.NET chapter 13. I based 15 or so forms on it and this is the only one that didn't work

polynomial5
 
Hi polynomial5d,

Thank you for posting in the community!

First of all, I would like to confirm my understanding of your issue. I'm
not very sure about your question. Do you mean that when you put all the
tables in one DataSet, the fields in the ComboBox cannot be shown properly
unless you make changes to the value in DataSet. And when the table Authors
is put in a separate table, the field are shown as we expected. If there is
any misunderstanding, please feel free to let me know.

From your description, I don't think there is anything wrong. Could you
please show us the code about how you filled the dataset and how you did
with databinding, so that I can reproduce the problem and we can help you
work out a solution more quickly? Please also let me know whether you're
working on an ASP.NET web app or a winform app, and which article you are
referencing? Could you paste the URL here? Thanks for your cooperation!

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Thank you Kevin

After I get back from the doctor this morning I will answer your questions

polynomial5d
 
Kevin, I'm afraid I didn't communicate very well. There are five comboboxes on the form. dsAuthorsTwo1 contains all the tables. I bound all the comboboxes to the selected value in the appropriate column in the authors table. For the datasource and display and value members I also used the appropriate table. For example, datasource dsauthorstwo1, display member pointsofView.PointOfView

Now the values appered in three comboboxes but not the other two

Fianlly, I used daAuthorsTwo to generate another dataset dsAuthors3, instantiated as dsAuthors31. For the two comboboxes for which I values were not showing, I changed the databinding. for primary pub combobox I used the databinding DsAuthors31 - Authors.PrimaryPublication, and same for the permission combobox

For the datasource, display member and value member I kept the old values, with all the tables. The new datasource, dsauthors31 had only one table in it, authors

With this change, the values showed in the two comboboxes. Everything else worked as well, add, cancel, update, edit, submit changes

As far as my source, I used a book, not an article on msdn. The book is ADO.NET Core Reference, Chapter 13

thanks

polynomial5

I know it works now, but I want to avoid such workarounds in the future and understand why the first dataset didn't show the values
 
Hi polynomial5d,

I can catch it this time. I think you mean when all the 5 tables are in the
same DataSet, two of the ComboBoxes cannot display the correct value.
However, if the main table is put into a separate DataSet, everything works
fine.

Based on my experience, this might be caused by incorrect use of
databinding. It seems to be a complicated issue, and needs further
debugging. If you can, please send me a package that can reproduce the
problem, so that I can deliver my assistance more quickly.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Well, I'm still not explaining myself exactly right.When the main table is put into a separate dataset, I'm only using the new dataset to bind the two comboboxes that weren't working. The other three that were working I left bound to the first dataset with all the tables in it

I don't know what further debugging I can do. I've put in so many watches and messageboxes and step throughs I don't know what else to do

I can send you the entire application. That's the only way you can see for yourself. In zip format. When the main form opens, click the tab that's labelled LookUp Forms. Then click Authors

polynomial5
 
I sent you the application. If you look at it, be sure to click on the LookupTable tab, then click the Authors form

thanks for all the trouble

polynomial5d
 
Hi polynomial5d,

I haven't received the package yet. Remove "online" from the no spam mail
is my real email address. The quota of a single mail attachment of the
server is 4MB, please try to make the package smaller if it is more than
4MB. I will reply to you as soon as I get any progress.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi polynomial5d,

After some debugging, I have found the problem. It seems that you have get
the wrong currency manager from the binding context. In your code Private
Sub Authors2_Load, you have get the currency manager with the following
code:

cm = CType(BindingContext(DsAuthorsTwo1.Authors), CurrencyManager)

This piece of code regard DsAuthorsTwo1.Authers as the data source.
However, the comboboxes accept DsAuthors as the data source.
BindingContext(DsAuthorsTwo1.Authors) and BindingContext(DsAuthorsTwo1,
"Authors") returns different binding contexts. Here I've made some changes
to the code.

cm = CType(BindingContext(DsAuthorsTwo1, "Authors"),
CurrencyManager)

After this, you can bind the other comboboxes back to the DsAuthorsTwo1
from DsAuthors31. HTH.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Thank you Kevin. It works, alright

I had a problem with controls on a windows form not behaving. The MVP there also debugged and found the same problem. It didn't work if I used ds.column but did work if I used ds, "column". Must be a subtle defect. Henceforth I'm going to use ds, "column"

Thanks again

polynomial5d
 
Hi polynomial5d,

You're welcome. Thanks for sharing your experience with all the people
here. If you have any questions, please feel free to post them in the
community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top