0

Ok so im reading int values from an sql database but then the "Executor" comes back as a hex value and it is declared as a int value in sql..all the bit field values i have comes back correctly accept the int values.
can someone help me ons this, what do i have to check for or what am i doing wrong

 While objDataReader.Read()
            cmbExecutor.SelectedItem.Value = objDataReader("Executor")
End while
3
Contributors
2
Replies
20
Views
4 Years
Discussion Span
Last Post by Eternal Newbie
0

Hi Try:

while objDataReader.read()
    cmbExecutor.selecteditem.value = objDataReader.GetInt32(0)
End While

Which will force it to supply the first integer value in the row

One Question though as you loop through the data rows returned by the data reader, you will be constantly changing the selected value of cmbExecutor, is this what you want to do? and if a value is returned from the database that has no match in the combobox items you will get an error

0

I think the problem here is: You're using selecteditem.value, which is - the value return after combobox clicked. To fill a combobox, I'll use .DataSource and .ValueMember:

Dim Dt as New DataTable
objDataReader.Fill(Dt)
cmbExecutor.DataSource = Dt
cmbExecutor.ValueMember = "Executor"

Edited by Eternal Newbie

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.