rickjamesb
MIS
In VB i have ONE drop down combobox that will display employee FirstName's, LastName's, & EmployeeID's from an Employee table.
To get all three attributes to fit into one combo box i used "AS EmployeeName" and i had to convert EmployeeID from an INT to NVarchar for it to run. The following procedure works fine:
CREATE PROCEDURE up_Display_Employees
AS
SELECT LastName + ', ' + FirstName + ' - ' + CAST (EmployeeID AS nvarchar(10))
AS EmployeeName
FROM Employees
Order by LastName
This SQL produces outputs like:
Dodsworth, Anne - 9
Fuller, Andrew - 2
Which is exactly the way i want it to show in the combo box.
The problem is with my VB code:
' Set SQL command specifics to fill the products grid
sqlCmd.CommandText = "up_Display_Employees"
sqlCmd.CommandType = CommandType.StoredProcedure
' Configure data adaptor and dill data set
sqlDatAdapNorthWinds.SelectCommand = sqlCmd
sqlDatAdapNorthWinds.Fill(datSetNorthWinds, "Employees")
cboEmployees.DataSource = datSetNorthWinds.Tables("Employees")
cboEmployees.DisplayMember = "LastName"
cboEmployees.ValueMember = "EmployeeID"
I'm not sure what to put as the DisplayMember and ValueMember and thats where the program keeps on getting errors. Any tips?
To get all three attributes to fit into one combo box i used "AS EmployeeName" and i had to convert EmployeeID from an INT to NVarchar for it to run. The following procedure works fine:
CREATE PROCEDURE up_Display_Employees
AS
SELECT LastName + ', ' + FirstName + ' - ' + CAST (EmployeeID AS nvarchar(10))
AS EmployeeName
FROM Employees
Order by LastName
This SQL produces outputs like:
Dodsworth, Anne - 9
Fuller, Andrew - 2
Which is exactly the way i want it to show in the combo box.
The problem is with my VB code:
' Set SQL command specifics to fill the products grid
sqlCmd.CommandText = "up_Display_Employees"
sqlCmd.CommandType = CommandType.StoredProcedure
' Configure data adaptor and dill data set
sqlDatAdapNorthWinds.SelectCommand = sqlCmd
sqlDatAdapNorthWinds.Fill(datSetNorthWinds, "Employees")
cboEmployees.DataSource = datSetNorthWinds.Tables("Employees")
cboEmployees.DisplayMember = "LastName"
cboEmployees.ValueMember = "EmployeeID"
I'm not sure what to put as the DisplayMember and ValueMember and thats where the program keeps on getting errors. Any tips?