?
Solved

Combobox table lookup

Posted on 2006-07-14
6
Medium Priority
?
240 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 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