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

Recommended Answers

All 2 Replies

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

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"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.