--____LPHMXLZMXOMRLFKSEJCW____
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,

I am trying to populate a dropdown combobox using:

Dim GetSQL As String =3D "Select QID, QuestionTypes " & _
"From QuestionTypesList " & _=20
"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 =3D ds.Tables("QT")
cmb_Qset.DataSource =3D dt
cmb_Qset.DisplayMember =3D "QuestionTypes"
cmb_Qset.ValueMember =3D "QID"
cmb_Qset.SelectedIndex =3D -1

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


Any ideas would be most welcome.

Cheers
Adam

--____LPHMXLZMXOMRLFKSEJCW____
Content-Type: multipart/related; boundary="____WHPEPQYSAQXEHDGESJXG____"


--____WHPEPQYSAQXEHDGESJXG____
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Diso-8859-1"=
>
<META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR></HEAD>
<BODY style=3D"MARGIN: 4px 4px 1px; FONT: 8pt Tahoma; COLOR: #000000">
<DIV>Hi,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I am trying to populate a dropdown combobox using:</DIV>
<DIV>&nbsp;</DIV>
<DIV>Dim GetSQL As String&nbsp;=3D "Select QID, QuestionTypes " &amp; =
_</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; "From QuestionTypesList " &amp; _ </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;"Order By QuestionTypes"<BR>Dim&nbsp;cn As New OleDb.OleDbCon=
nection(Globals.udl0Val)<BR>Dim da As New OleDbDataAdapter(GetSQL, =
cn)<BR>Dim ds As New DataSet<BR>cn.Open()<BR>da.Fill(ds, "QT")<BR>cn.Close(=
)</DIV>
<DIV>Dim dt As New DataTable<BR>dt =3D ds.Tables("QT")</DIV>
<DIV>cmb_Qset.DataSource =3D dt<BR>cmb_Qset.DisplayMember =3D "QuestionType=
s"<BR>cmb_Qset.ValueMember =3D "QID"</DIV>
<DIV>cmb_Qset.SelectedIndex =3D -1</DIV>
<DIV>&nbsp;</DIV>
<DIV>It is failing at the da.fill with an unhandled exception in System.Dat=
a.Dll</DIV>
<DIV>&nbsp;</DIV>
<DIV>Any ideas would be most welcome.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Cheers</DIV>
<DIV>Adam</DIV></BODY></HTML>

--____WHPEPQYSAQXEHDGESJXG____--

--____LPHMXLZMXOMRLFKSEJCW____--

Re: Populate combobox failing at da.Fill by Mike

Mike
Mon Oct 25 09:17:40 CDT 2004

Adam Maltby wrote:

> 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