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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top