Junaid Mangerah
Junaid Mangerah

Reputation: 33

class cannot be indexed because it has no default property

Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click

    MySqlConn = New MySqlConnection
    MySqlConn.ConnectionString = "Server = Localhost; database = venuesdb; user id = root; Password = "

    Dim SQLDataAdapter As New MySqlDataAdapter
    Dim DatabaseDatSet As New DataTable
    Dim Bindsource As New BindingSource
    Dim Command As MySqlCommand


    Try
        MySqlConn.Open()
        Dim Query = "Select * From venuesdb.Event "
        Command = New MySqlCommand(Query, MySqlConn)
        SQLDataAdapter.SelectCommand = Command()
        SQLDataAdapter.Fill(DatabaseDatSet)
        Bindsource.DataSource = DatabaseDatSet
        DataGridView1.DataSource = Bindsource
        SQLDataAdapter.Update(DatabaseDatSet)
        MySqlConn.Close()

    Catch ex As Exception
        MessageBox.Show(ex.Message)

    End Try
    MySqlConn.Dispose()
End Sub

it says "Class 'Mysql.Data.MySqlClient.MySqlCommand cannot be indexed because it has no default property."

Whats the problem with it??

Upvotes: 0

Views: 2043

Answers (1)

Bradley Uffner
Bradley Uffner

Reputation: 16991

Get rid of the parens on Command.

SQLDataAdapter.SelectCommand = Command

The parens indicate a function call (or indexed property) rather than the assignment you want in this case.

Upvotes: 1

Related Questions