KrAzY
asked on
DropDownList w/ DataSource - How to Combine 2 Fields (LastName, FirstName)?
Ok, I am using Microsoft SQL With Stored Procedures. I run a Query that returns the First Name and Last Name of all the users in the Database. I then return that and try and fill a DropDownList with this Format "Last, First". I can get just one field to successfully fill, like Last Name, but I can't seem to figure out how to combine Last Name and First Name.
Here is some Code:
1. SQL Calling Stored Procedure
' Execute the command
myConnection.Open()
Dim result As SqlDataReader = myCommand.ExecuteReader(Co mmandBehav ior.CloseC onnection)
' Return the datareader result
Return result
2. Filling the DropDownList (The Code Below works for Last Name)
Me.ddlStudentDetail.DataSo urce = dbGradSite.StudentFullName ()
Me.ddlStudentDetail.DataVa lueField = "LastName"
Me.ddlStudentDetail.DataTe xtField = "LastName"
Me.ddlStudentDetail.DataBi nd()
Now, as I said before I want "LastName, FirsName". Any help/advice would be appreciated.
Thanks.
Here is some Code:
1. SQL Calling Stored Procedure
' Execute the command
myConnection.Open()
Dim result As SqlDataReader = myCommand.ExecuteReader(Co
' Return the datareader result
Return result
2. Filling the DropDownList (The Code Below works for Last Name)
Me.ddlStudentDetail.DataSo
Me.ddlStudentDetail.DataVa
Me.ddlStudentDetail.DataTe
Me.ddlStudentDetail.DataBi
Now, as I said before I want "LastName, FirsName". Any help/advice would be appreciated.
Thanks.
ASKER
I tried that and this is what I got:
DataBinder.Eval: 'System.Data.Common.DbData Record' does not contain a property with the name LastName , Firstname.
DataBinder.Eval: 'System.Data.Common.DbData
Is this what you ar looking for?
myConnection.Open()
Dim objRes
set objRes = myConnection.execute("exec sp_something")
while not objRes.eof
response.write objRes("FirstName")
response.write objRes("LastName")
objRes.movenext
wend
myConnection.Open()
Dim objRes
set objRes = myConnection.execute("exec
while not objRes.eof
response.write objRes("FirstName")
response.write objRes("LastName")
objRes.movenext
wend
ASKER
No that is not what I am looking for...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent, that did it. I had to modify it a little according to MS SQL Syntax:
SELECT
(LastName + ', ' + FirstName) AS FullName
FROM
Students
Thanks again.
SELECT
(LastName + ', ' + FirstName) AS FullName
FROM
Students
Thanks again.
SELECT
(LastName + ' ' + FirstName) AS FullName
FROM
Students
(LastName + ' ' + FirstName) AS FullName
FROM
Students
ASKER
Thanks... Vilas, but I already got it from poxy. I wanted the ',' in there to seperate the names.
Me.ddlStudentDetail.DataSo
Me.ddlStudentDetail.DataVa
Me.ddlStudentDetail.DataTe
Me.ddlStudentDetail.DataBi