SQLReader and combobox

  • Thread starter Thread starter Eva
  • Start date Start date
E

Eva

Hi,

Im trying to use the SQLReader to populate a combobox. I
am running a stored procedure that selects a single
coloumn from a table. can anyone help me on what to
write. here is what i have done so far.

Try
Cn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader
While reader.Read
ComboBox1.Items.Add(reader.GetSqlString())
End While
Catch ex As Exception
MsgBox(ex.Message)
Finally
Cn.Close()
End Try

The reader.GetSqlString is being rejected for some
reason. Does anyone know why?
 
You need to pass it the column index. Since your query
returns only one column, it shound be:

reader.GetSqlString(0)

Donald Xie
 
Hi Donald,

I have tried this but i do not seem to be getting any
values returned in my combobox at runtime!!!

Any idea why this maybe the case?
 
Back
Top