#8 MySQLDataAdapter.Fill

open
nobody
None
5
2004-05-03
2004-05-03
Don
No

Can't fill a dataset. Error message:

System.InvalidCastException: Specified cast is not valid.
at
System.Data.Common.DbDataAdapter.FillFromCommand(Object
data, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet
dataSet, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet
dataSet)
at TestMySQL.Form1.Button1_Click(Object sender,
EventArgs e) in [...] Form1.vb:line 128

Here's the code:

Friend ppConnection As MySQLDriverCS.MySQLConnection
Friend ppOrderAdapter As MySQLDriverCS.MySQLDataAdapter
Friend WithEvents DataSet1 As System.Data.DataSet

Dim ppOrderSelect As String = "SELECT <fld1>,
<fld2>, [...] " & _
"FROM Prodplan.Orders;"

Dim ppConnectStr As String = _
"SERVER=localhost;" & _
"Initial Catalog=ProdPlan;" & _
"User ID=<UID>;PASSWORD=<pwd>;"

ppConnection = New
MySQLDriverCS.MySQLConnection(ppConnectStr)
'ppSelectCommand = New
MySQLDriverCS.MySQLCommand(ppOrderSelect, _
' ppConnection)
ppOrderAdapter = New
MySQLDriverCS.MySQLDataAdapter _
(ppOrderSelect, ppConnection)
Dataset1 = new System.Data.Dataset

ppOrderAdapter.Fill(Me.Dataset1)

Discussion