DataSource not IListSource or IEnumerable

2003-03-02
2004-02-04
  • Adrian Aitken
    Adrian Aitken
    2003-03-02

    When trying to bind to a drop down listbox I get the above message. According to the docs. MySQLDriverCS is IDataReader compliant so shouldn't it utilise IListSource or IEnumerable ?
    As you can see from the following code I want to get away from reading each record manually (the commented out code works) ...

        Dim mySQLCmd As MySQLCommand = New MySQLCommand("Select ID , FullName  from Service where ID > 1 order by Fullname ;", mySQLConn)
        Dim mySQLData As MySQLDataReader = mySQLCmd.ExecuteReader()

    '    While mySQLData.Read()
    '        qryService.Items.Insert(0, new ListItem(mySQLData("FullName"), mySQLData("ID")))
    '    End While

        qryService.DataSource = mySQLData
        qryService.DataValueField = "id"
        qryService.DataTextField = "name"
        qryService.databind()

        qryService.Items.Insert(0, new ListItem("Any", "0"))
        mySQLdata.close
        mySQLData = Nothing
        mySQLCmd = Nothing
           

     
    • Jose Arvelo
      Jose Arvelo
      2003-04-14

      I get the same message when I try databinging my DataGrid. Here's the relevant code:

              dim strSQL as string = "select * from employees"
              dim db_sqlCommand as new mySQLCommand(strSQL, db_MySQLConn)
              db_mySQLConn.open()
         
              dim db_sqlReader as MySQLDataReader
              db_sqlReader = db_sqlCommand.executeReader()
         
              dgEmployees.datasource = db_sqlReader
              dgEmployees.databind()
              db_sqlReader.close
              db_mySQLConn.close

       
    • Joe Henderson
      Joe Henderson
      2003-04-18

      I ran into this same issue in .Net using SQL Server.  To bind to a DataGrid, I had to use a DataSet rather than a SqlDataReader.  Since I haven't used MySQL yet, I don't know if this software supports executeDataSet, but if it does, that's what you should use.

       
    • Hexane
      Hexane
      2004-02-04

      Big hole right here.  If this driver can't execute a dataset, it's pretty much useless.

      :(