Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > From Drop-down list SQL-- can;t get "order by" to work View modes: 
User avatar
Member
Member
mkidd-Repairclinic - 2/1/2013 12:01:04 PM
   
From Drop-down list SQL-- can;t get "order by" to work
I set up a form with a drop-down list that pulls user names. It started out simply:

SELECT FullName,FullName
FROM dbo.CMS_User

This works fine, but I needed to hide users that are marked as "hidden". So I tried this:

SELECT FullName,FullName
FROM dbo.CMS_User
WHERE UserIsHidden = 0

That leaves out hidden users in the dropdown list as it should, but the names are out of alpha order. So I tried this:

SELECT FullName,FullName
FROM dbo.CMS_User
WHERE UserIsHidden = 0
ORDER BY FullName

I believe this is proper SQL-- it works in a MS SQL Server query, but the page that shows the form gives this error:

[Error loading the FormControl '']
[DataConnection.HandleError]: Query: Select FullName,FullName from dbo.CMS_User where UserIsHidden = 0 Order by FullName: caused exception: Ambiguous column name 'FullName'.

How can I get this working?

Thanks for your help.

User avatar
Certified Developer 13
Certified Developer 13
kentico-jx2tech - 2/1/2013 12:21:36 PM
   
RE:From Drop-down list SQL-- can;t get "order by" to work
Try naming the FullName fields differently...

SELECT FullName AS [value], FullName AS [text]
FROM dbo.CMS_User
WHERE UserIsHidden = 0
ORDER BY FullName

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 2/1/2013 7:50:51 PM
   
RE:From Drop-down list SQL-- can;t get "order by" to work
You can also ORDER BY <column index>. So if you have selected FullName, FullName, FirstName, LastName, if you ORDER BY 1, it will order by the first FullName Column.