-1

This is what I have that is giving me the unable to bind error

    Dim STSQL = <sql>SELECT Employee_id, First_name, MIDDLE_INITIAL, last_name,
       (Employee_id || ' ' || First_name || ' ' || last_name) As EmpName
    FROM mpcs.Employee</sql>.Value


    rsMPCS = MPCS_SELECT_SQL(UCase(STSQL), rsMPCS)

    dtEmp = New DataTable
    dtEmp.Load(rsMPCS)

    cboEmployee.DataSource = dtEmp
    cboEmployee.DisplayMember = "EmpName"
    cboEmployee.ValueMember = "ID"
Lee
  • 95
  • 2
  • 9
  • I have no idea what `rsMPCS` or `MPCS_SELECT_SQL` are. The error is an Oracle one because on Oracle, CONCAT takes 2 and only 2 arguments. So just glue several together: http://www.techonthenet.com/oracle/functions/concat.php and shown here http://stackoverflow.com/questions/1619259/oracle-sql-concatenate-multiple-columns-add-text (assuming it *is* Oracle - I'm just going on the error, I thought you had MySQL for previous Qs). – Ňɏssa Pøngjǣrdenlarp Apr 13 '16 at 18:54
  • You have apparently never used bound datasources. The ValueMember and DisplayMember are supposed to be the names of the Properties or members you want to bind to. In this case, they would be column names in the datatable. You dont have a column named `Id`, use `Employee_id` – Ňɏssa Pøngjǣrdenlarp Apr 14 '16 at 13:15
  • I am very novice I know. Doing this on this site helps me tremendously though, I keep notes, I save everything and eventually I'll be better. So now when I do `cboEmployee.SelectedValue` it will always give me the Employee_ID selected correct? – Lee Apr 14 '16 at 13:40

1 Answers1

0

first change this

Public ArrEmployee(3, 0) As String

to

Dim x as Integer = number of employees( if you don't know put it larger than expected)
Public ArrEmployee(x, 3) As String

Then this part should be this way

ArrEmployee(x, 0) = rsMPCS("Employee_id")
ArrEmployee(x, 1) = rsMPCS("First_name")
ArrEmployee(x, 2) = rsMPCS("MIDDLE_INITIAL")
ArrEmployee(x, 3) = rsMPCS("last_name")
x += 1

Finally when you want to add to combobox

For x = 0 To UBound(ArrEmployee, 2) - 1
    Dim textToAdd As String = String.Format("{0} {1} {2} {3}", ArrEmployee(x, 0), ArrEmployee(x, 1), ArrEmployee(x, 2), ArrEmployee(x, 3))
    cboEmployee.Items.Add(textToAdd)
Next

Said that, you should really make employee class and then list of that class. It would be easier in long run, neater and done properly.

Claudius
  • 1,883
  • 2
  • 21
  • 34