Possible help for Newbie

  • Thread starter Thread starter Not Bright
  • Start date Start date
N

Not Bright

Hi All,

Hope everyone is well and wouldn`t mind helping a very frustrated newbie
out? Im fairly new to VB 2005. I have made a fair very simple Database
Projects which have all worked. Im now writing a very simple project which
has a Table, and 3 Combo Box`s which are set as Lookups to other tables. My
problem is I can get the Combo Box`s to display the right information. Also
when I Click on a different row on my datagrid the ComboBox`s do not update
with the new values, instead it stays on the value of the first row in the
table. I`ve been search and goggling for nearly 2 weeks now and can`t find
anything similar, Demo or How to. I`ve looked on MDSN and know I need
concurrency and Binding but im so confused reading it.

I`ve posted my project on:

http://www.network-db.co.uk/downloads/SmallVBApp.zip

For anyone to download ans see what i mean. Unfortunalty im one of these
people who as I don`t really fully understand VB and don`t know how to
explain what I mean? I hope I havn`t confused anyone on here?

I just wonder if somebody could have a look and point me in the right
direction or give me a bit of code which could help?

Many thanks and sorry for probably been daft
Regards
SG
 
Hi,

Not Bright said:
Hi All,

Hope everyone is well and wouldn`t mind helping a very frustrated newbie
out? Im fairly new to VB 2005. I have made a fair very simple Database
Projects which have all worked. Im now writing a very simple project which
has a Table, and 3 Combo Box`s which are set as Lookups to other tables.
My problem is I can get the Combo Box`s to display the right information.
Also when I Click on a different row on my datagrid the ComboBox`s do not
update with the new values, instead it stays on the value of the first row
in the table. I`ve been search and goggling for nearly 2 weeks now and
can`t find anything similar, Demo or How to. I`ve looked on MDSN and know
I need concurrency and Binding but im so confused reading it.

I`ve posted my project on:

http://www.network-db.co.uk/downloads/SmallVBApp.zip

For anyone to download ans see what i mean. Unfortunalty im one of these
people who as I don`t really fully understand VB and don`t know how to
explain what I mean? I hope I havn`t confused anyone on here?

I just wonder if somebody could have a look and point me in the right
direction or give me a bit of code which could help?

A couple of problems:

1) In Form_Load you are loading the CompanyInfo table twice, no need for
that.

2) CompanyInfo.Product is text not a foreign key which means your db is
probely not in the 3th normal form, although sometimes this is wanted, so i
can't really say this is wrong or good.

3) You need to set a DataSource, DisplayMember and ValueMember on
CompanyComboBox, using the designer you select the ComboBox and look at the
property window.
CompanyComboBox.DataSource = CompanyBindingSource
CompanyComboBox.DisplayMember = "Company"
CompanyComboBox.ValueMember = "CompanyID"

4) You also need to bind CompanyComboBox to the CompanyInfoBindingSource
using SelectedValue or Text, but never BOTH at the same time!!
- if CompanyInfo.Product is text (ie not a foreign key) then use Text:
CompanyComboBox
(DataBindings)
Text : CompanyInfoBindingSource - Product
SelectedValue : none
SelectedItem : none

- if CompanyInfo.Product would be a number (foreign key) then you would use
SelectedValue:
CompanyComboBox
(DataBindings)
Text : none
SelectedValue : CompanyInfoBindingSource - ProductID
SelectedItem : none

Again, you only bind SelectedValue, Text or SelectedItem but rarely more
then one of them, if you made a mistake you need to clear them, set them to
none.

HTH,
Greetings
 
Great Stuff,

Many, Many Thanks for you help. I`ll give it a go tonight:)

Many Thanks Again
SG
 
Thank you so much ! I've been cursing at this thing for hours !

This is also true for C# by the way for anyone like me who found this
through Google or another search engine.

You are a life saver. Thanks again

A.
 
Back
Top