jhowe
jhowe

Reputation: 10828

lightswitch create lookup list

I've created a simple contact database with three tables, Corporate, Contact, and Country. I've created a LightSwitch application on top of it and am trying to create a countrycode lookup. i.e. on the new Corporate screen, for countrycode field have a lookup list coming from the country table.

How can I do this? If I was writing a SQL query it would purely be:

SELECT CountryCode 
FROM Country  

In the query designer it makes you create filters, I don't want to add any filters! Also, I've created foreign keys, unique key constraints but LightSwitch doesn't seem to recognise them and complained when I was importing my tables?

* UPDATE *

Error below

enter image description here

enter image description here

Upvotes: 0

Views: 688

Answers (1)

Yann Duran
Yann Duran

Reputation: 3879

Normally, if relationships are set up correctly, this would just happen for you automatically. LightSwitch is very good at this actually.

If I understand correctly, your data source is an external SQL database, that you've added into your LightSwitch application as an attached data source. If there was a relationship between the Client table & the Country table, then LightSwitch would create the look-up combo box in the Client screen automatically. But it's not enough to just have a foreign key column, you have to create a relationship between the two tables.

You don't mention what the columns are in your tables, or more importantly the column data types are. The Country table should have an integer primary key, plus a text column for the name. In the Client table, it should also have an integer primary key, plus an integer foreign key. The relationship should be created in the Client table between its Country foreign key column and the Country table's primary key column.

You mentioned that LightSwitch "complained" when you were importing your tables. What was the error message?

Upvotes: 1

Related Questions