Start New Discussion within our Software Development Community

Seems like this should be simple. I am binding comboboxes successfully to my Access DB. It looks like this:

Dim da As New OleDbDataAdapter(asql, con)
Dim ds As New DataSet
da.Fill(ds)
cboEmployeeNumber.ValueMember = "ID"
cboEmployeeNumber.DataSource = ds.Tables(0)
cboEmployeeNumber.SelectedIndex = 0

Works great. Then I try to bind a text box and I get any number of errors based on which version I try. I feel like I am going about this the wrong way. Below are some of the variations I have tried without success:

txtTypeOfEvaluation.Text = "Classification"
txtTypeOfEvaluation. = ds.Tables(0)
txtTypeOfEvaluation.DataBindings.Add("Text", ds, "2013Employees.Classification")

txtTypeOfEvaluation.DataBindings.Add("Text", ds, "Employees.Classification")

Me.txtTypeOfEvaluation.DataBindings.Add("text", ds.Tables("Employees"), "Classification")

Me.txtTypeOfEvaluation.DataBindings.Add(New Binding("Text", myDataSet.Tables("Employees"), "Classification", True))

txtTypeOfEvaluation.DataBindings.Add(New Binding("Text", ds.Tables("Employees"), "Classification"))

Me.txtTypeOfEvaluation.Text = ds.Tables("Employees").Rows(0).Item(14)

Thoughts?

What errors are you receiving?

Try placing the code in a try/catch:

Try
    'Your code here.
Catch ex As Exception
    MsgBox(ex.ToString)
End Try

If the following code:

Me.txtTypeOfEvaluation.Text = ds.Tables("Employees").Rows(0).Item(14)

Had thrown errors, I suspect an index out of range, or some kind of exception.

I would try:

txtTypeOfEvaluation.Text = IIF(IsDBNull(ds.Tables("Employees").Rows(0)("Classification")),String.Empty,ds.Tables("Employees").Rows(0)("Classification"))
This article has been dead for over six months. Start a new discussion instead.