Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2007

Tip: Looking for answers? Try searching our database.

ComboBox updating data source via look-up table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave S. - 25 Jan 2007 22:32 GMT
Hi - first post and not quite sure which board to post to as it involves
windows forms and data access .... sorry if wrong one chosen!

I am developing a database project for my small vehicle trading business,
and thus have  a cars table and (among others) a colours table. I use a combo
box as a look up to pick a colour for a car and all works well .... until I
want to add a new colour to the colour table and at the same time select this
new colour as the one relevant to the current car. I add the new colour to
the colour table by calling a stored procedure and sure enough the new colour
is stored. But when I save the new record the old colour is the one STILL
associated with that record.

I have tried playing around with lots of things but can't get the behaviour
I want. I hope I've explained my problem clearly, any help greatly
appreciated!!! Dave
Otis Mukinfus - 26 Jan 2007 02:54 GMT
>Hi - first post and not quite sure which board to post to as it involves
>windows forms and data access .... sorry if wrong one chosen!
[quoted text clipped - 11 lines]
>I want. I hope I've explained my problem clearly, any help greatly
>appreciated!!! Dave

I presume you are storing the colors in a lookup table and joining the Car and
color tables to get the main row of data, then linking the combobox to the car's
color via the row id of the colors table.  If you are doing that then you will
need to do an update of the row in the car table that changes the id in the
column of the car table that links the car with the color.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Dave S. - 26 Jan 2007 20:26 GMT
Hi Otis, thanks for the reply. You got the gist of it. What I'm trying to do
is to replicate the 'NotInList' property of combo boxes available in Access.
I can change the colour of the car in the car table through the combo box if
the colour already exists - the trouble comes when I want to add a new
colour! (and it's usually when adding a new car that I want to add a new
colour!) . I am being lazy really using the bindingsource and navigator
controls in .net 2005 rather than coding the updates manually, but as the
behaviour was available in Access I can't believe you can't replicate it in
.net!! Maybe you can't!

> >Hi - first post and not quite sure which board to post to as it involves
> >windows forms and data access .... sorry if wrong one chosen!
[quoted text clipped - 23 lines]
> http://www.arltex.com
> http://www.tomchilders.com
Otis Mukinfus - 27 Jan 2007 01:52 GMT
>Hi Otis, thanks for the reply. You got the gist of it. What I'm trying to do
>is to replicate the 'NotInList' property of combo boxes available in Access.
[quoted text clipped - 5 lines]
>behaviour was available in Access I can't believe you can't replicate it in
>.net!! Maybe you can't!

Hello again Dave,

Having not developed an Access application since 1996, I'm kind of hazy on what
you mean by the 'NotInList' property.  However I'll try to be a little more
specific regarding what I said earlier on.

I'm not sure you will be able to automatically cause the new color to be added
to the color table through databinding.  That doesn't mean you can't do it it
just means I don't know how to do it.

Now if I were going to do what I think you want to do (and I would do it
manually)  I guess I would set the ComboBox.DropDownStyle to
DropDownStyle.DropDown so the user can enter the new color

Now pseudo code here down:

User enters the color
User clicks the go button
Get the color name from the Combobox.TEXT property
Insert that color into your color table and retrieve the row id of the newly
created row from the table.
Add the Color to the Combobox's Items list and add the row id the to
corresponding value items list.

Update the column in the row describing the car with the id of the color the
user entered.

After doing that, the next time you pull that row from the car table you will
get the correct color and the combobox will also contain the new color in it's
item list.

That's how I would do it, but there is probably some one reading this who knows
an easier way through binding.

Even if you do it manually and are using a strong typed dataset there will
probably only be a few lines of code required, since with a strongly typed DS
you have insert, update and delete methods on the tables the dataset includes.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Dave S. - 30 Jan 2007 13:30 GMT
Hi Otis,

Thanks for your input. I've managed to achieve it using various flags etc.
It's functional but far from pretty! The 'NotInList' method of an Access
combobox enables a user to add data to one table and then take the id of the
newly added item as a value in the foreign key table in one relatively
effortless motion! Just thought .net would offer the same capability. Perhaps
it does, but if so it's buried in the help files beyond my reach! Perhaps
I'll post a similar question in a data related group to see if anyone has any
ideas. Thanks again for your time and trouble. Dave

> >Hi Otis, thanks for the reply. You got the gist of it. What I'm trying to do
> >is to replicate the 'NotInList' property of combo boxes available in Access.
[quoted text clipped - 49 lines]
> http://www.arltex.com
> http://www.tomchilders.com

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.