Connecting Tech Pros Worldwide Help | Site Map

ComboBox problem

Newbie
 
Join Date: Apr 2009
Posts: 13
#1: May 12 '09
Hi all. I am using VS2008 Pro. I have a simple DVD database built. I'm trying to make a data driven app to store my dvd collection.

One of my tables is Actors and is structured as follows.

ActorID - int - PK
LastName - varchar(20)
FirstName - varchar(20)

On a form in my app I have a combobox. I'm trying to make it list FirstName LastName ie. Will Smith. I know how to make a query that'll take the LastName and FirstName fields and list it as Actor. I'm having a heck of a time getting it to do that in the combobox as it'll only let me use one field for the display and won't let me use the query I've made...

Expand|Select|Wrap|Line Numbers
  1. SELECT FirstName + ' ' + LastName AS Actor
  2. FROM Actors
  3. ORDER BY LastName
  4.  
I keep getting some error about schema don't match default query. I know I could simply change the table to only have one field that holds first and last name, but from what I understand that's not proper db practice. I've searched this site and google until I was blue in the face at looking at soulutions that don't match what I'm trying to do. Does anyone know of a trick to do this?
searockruz's Avatar
Newbie
 
Join Date: May 2009
Location: Jupiter
Posts: 7
#2: May 20 '09

re: ComboBox problem


can you post your code,so that i can help you
Newbie
 
Join Date: Apr 2009
Posts: 13
#3: May 21 '09

re: ComboBox problem


It's not really a code problem. It's actually a problem knowing which buttons to push (so-to-say) to get the result I want. I actually figured it out, but deleted the project where I was testing thinking I'd get back to it the next day. Then work happened bla. Been out of town for 2 weeks and can't remember what I did. Anyway I'll figure it out again.

I think I had to make a new view or something of the such in SQL Server then use that view to populate the combo box.
daniel aristidou's Avatar
Needs Regular Fix
 
Join Date: Aug 2007
Posts: 493
#4: Jun 14 '09

re: ComboBox problem


what you want to look at is the data binding properties of the combo box, when you are in design view. from here you can select which columns are shown, and which columns value will be used when using the combo box.
Reply


Similar Visual Basic .NET bytes