Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Combobox table lookup

Posted on 2006-07-14
6
237 Views
Last Modified: 2010-04-23
Hi guys.

This is a simple one but can't get it to work.

VB.net with an Access Database.

I have a customer table with a marketing ID field (type: number) and this links to a Marketing table which also has a MarketingID field (type: Autonumber) and a Marketing field. I now have a form in VB.net for entering new customers and viewing exsiting. This form did contain an oleDataAdapter with the query "SELECT * FROM Customer" and a dataset dsCustomer1 and I could enter info for the customer.

I now want to allow the user to enter where the customer heard about us via a combobox and a link to this Maketing table. This will contain "TV, radio, press ...". How do I do this.

Do I create another oleDataAdapter with the query "SELECT * FROM Marketing" and add this to a new or existing dataset. Or do I merrge this query with the existing one using JOIN or WHERE??? I've had a go and also have heard of this datarelation object I should be using which I can't remember from VB 6.

Many thx

0
Comment
Question by:adampdarcy
  • 2
  • 2
6 Comments
 
LVL 6

Expert Comment

by:manch
ID: 17106996


Use the existing Data set

and use the combobox properties (DataSource, DisplayMember, ValueMember properties )

0
 
LVL 24

Accepted Solution

by:
Jeff Certain earned 125 total points
ID: 17107614
You can either add the table to the existing dataset, or you can create a new table. Since you're not going to be creating datarelation objects, you really don't need the overhead of the dataset; it's just a convenient way to group tables.

You ought to avoid using *; instead you should explicitly state what fields you want. This has a few effects.
1. More efficient queries, since the database engine doesn't need to look up your field names to resolve the *.
2. Transferring less data since, often, you don't need every column in the table.
3. It results in a consistent query. You shouldn't really be using positional references to your columns, but the order of coumns in a datagrid, for example, will change if the columns are autogenerated and you make database table changes.

To be more specific about the syntax for the combo box binding:

    With myComboBox
      .DataSource = ds.Tables("Marketing")
      .DisplayMember = "MarketingType"
      .ValueMember = "MarketingId"
    End With
0
 

Author Comment

by:adampdarcy
ID: 17107785
This I have tried with no success.

I've got two data adapters, one for each table, and have put them both in the same dataset.

The combobox simply displays nothing?
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 17107839
Code please? Specifically, where you create the adapters and fill the tables.
0
 

Author Comment

by:adampdarcy
ID: 17108456
I havn't written it it in code as I've used the dataAdapter tools in the form designer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question