[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Combobox table lookup

Posted on 2006-07-14
6
Medium Priority
?
242 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
[X]
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
  • 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 250 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 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