inserting data into combobox problem

inserting data into combobox problem

Postby arif_amm » Tue 01 May 2007 22:26

i try this code

Code: Select all
Imports CoreLab.MySql
Imports CoreLab.Data
Imports MySql.Data.MySqlClient
Imports System.Data

Public Class Form1
    Public conn As New MySqlConnection("User ID=root;Password=mysql;Host=192.168.0.5;Port=3306;Database=test;pooling=true")


    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Try
            conn.Open()
            Dim cmd As MySqlCommand = New MySqlCommand("select username  from muser")
            cmd.FetchAll = True
            cmd.Connection = conn
            Dim reader As MySqlDataReader = cmd.ExecuteReader()
            For Each rec As IDataRecord In reader
            combobox1.Items.Add(rec("username"))
            Next
            reader.Close()
            conn.Close()
        Catch ex As MySqlException
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Connection failed")
        End Try

    End Sub
End Class



the error apears in " For Each rec As IDataRecord In reader ".
i try this in widows application and it's work.why it does not work for pocket pc.any idea how to input data from table to combobox? thnak you..
arif_amm
 
Posts: 3
Joined: Mon 30 Apr 2007 05:38

Postby Serious » Thu 03 May 2007 09:55

You should invoke the reader.Read() method and check its return value before trying to access the MySqlDataReader data.
Serious
 


Return to dotConnect for MySQL