I want to return distinct values from a table in uppercase
Have tried
SELECT UPPER DISTINCT fieldname FROM tablename
But returns an error, what is the correct syntax.
ThanksNearly, upper is a function so you need to provide a column as an argument.
Select distinct upper(fieldname) from tablename|||Thanks,
However that now causes an error, my select statement is now:
SELECT DISTINCT UPPER (maketext) from VsVehicles WHERE dealerrefnum=8479
This is used in a datareader i.e.
Dim MySQL As String = "SELECT DISTINCT UPPER (maketext) from VsVehicles WHERE dealerrefnum=8479"
Dim MyConnection As New SqlConnection(ConnectionString)
Dim DataReader As SqlDataReader
Dim SQLCommand As New SqlCommand(MySQL, MyConnection)
MyConnection.Open()
DataReader = SQLCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
DropDownList1.DataSource = DataReader
DropDownList1.DataTextField = ("maketext")
DropDownList1.DataBind()
The error message is:
DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a property with the name maketext.
Thanks
Ben|||it doesnt seem to be the problem with the upper word. check if the col name is correct..
hth|||When you run a column through a function, you need to provide the result with an alias:
SELECT DISTINCT UPPER (maketext) AS maketext from VsVehicles WHERE dealerrefnum=8479
SELECT SUM(Volume) AS Volume FROM MilkBottles|||nope an alias is not necessary...unless you want to parse through the loop ( if the query returns one ) or get the value into a variable...you dont need an alias when you use a function...alias is only a way to identify the column...
hth|||Well, I could be wrong, but he is databinding to a datareader, and setting the DataTextField to a column named "maketext."
His query:
SELECT DISTINCT UPPER (maketext) from VsVehicles WHERE dealerrefnum=8479
returns no columns named "maketext." It does include a column (with no column name) derived from the column named "maketext", but no actual column named "maketext".
My guess is that aliasing the column name will solve his problem...|||i see what you mean...i was looking at the select stmt all the while...
::nope an alias is not necessary...unless you want to parse through the loop ( if the query
::returns one ) or get the value into a variable...you dont need an alias when you use a
::function...alias is only a way to identify the column...
from my stmt, i meant the same thing by saying "get the value into a variable"
i was prbly not clear...good you clarified it out..
dinakar|||Yes that worked, thankyou
SELECT DISTINCT UPPER (maketext) AS maketext FROM VsVehicles
Thanks
Bensql
No comments:
Post a Comment