Populate combobox failing at da.Fill

A

Adam Maltby

Hi,

I am trying to populate a dropdown combobox using:

Dim GetSQL As String = "Select QID, QuestionTypes " & _
"From QuestionTypesList " & _
"Order By QuestionTypes"
Dim cn As New OleDb.OleDbConnection(Globals.udl0Val)
Dim da As New OleDbDataAdapter(GetSQL, cn)
Dim ds As New DataSet
cn.Open()
da.Fill(ds, "QT")
cn.Close()
Dim dt As New DataTable
dt = ds.Tables("QT")
cmb_Qset.DataSource = dt
cmb_Qset.DisplayMember = "QuestionTypes"
cmb_Qset.ValueMember = "QID"
cmb_Qset.SelectedIndex = -1

It is failing at the da.fill with an unhandled exception in System.Data.Dll

Any ideas would be most welcome.

Cheers
Adam
 
M

Mike Edenfield

Adam said:
Dim GetSQL As String = "Select QID, QuestionTypes " & _
"From QuestionTypesList " & _
"Order By QuestionTypes"
Dim cn As New OleDb.OleDbConnection(Globals.udl0Val)
Dim da As New OleDbDataAdapter(GetSQL, cn)
Dim ds As New DataSet
cn.Open()
da.Fill(ds, "QT")
cn.Close()
It is failing at the da.fill with an unhandled exception in System.Data.Dll

Most of the time, this is due to bad SQL. Can you run the SQL against
the database directly? Or try creating an explicit OleDbCommand object
and run ExecuteReader(). Both of these will help eliminate problems
with the SQL statement itself being the problem.

--Mike
 

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

Top