Imports MySql.Data.MySqlClient

Public Class Form8
    Dim connection As MySqlConnection

    Dim con As MySqlConnection
    Dim da As MySqlDataAdapter
    Dim dt As DataTable
    Dim strQuery As String



    Private Sub Form8_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        strQuery = "server=localhost; user id=root; password=phoenix0931; database=accounts;"
        con = New MySqlConnection(strQuery)
        con.Open()
        Me.Text = con.State.ToString
        strQuery = "Select * from customers"
        da = New MySqlDataAdapter(strQuery, con)
        dt = New DataTable
        da.Fill(dt)
        With ComboBox1
            .DataSource = dt
            .DisplayMember = "customer_name"
            .ValueMember = "customers_id"

        End With








    End Sub




    Private Sub ComboBox1_SelectionchangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted

        con.Open()

        strQuery = "Select * from customers Where customer_id=" & ComboBox1.SelectedValue
        da = New MySqlDataAdapter(strQuery, con)
        dt = New DataTable
        da.Fill(dt)
        TextBox2.Text = dt(0)(0)<------ error goes here in this line the (dt)



    End Sub


End Class

This is my Code the error is Class 'System.data.datatable' cannot be indexed because it has no default property.. When i try this code in oledb it works but here it wont..

Can anyone explain my error??

i know my error NOw.. :)

it shoud be like this

TextBox2.Text = dt.Rows(0)("customer_add").ToString()

hope that it would help :D

This question has already been answered. Start a new discussion instead.