Can anyone help me out pls
Unable to display data in datagridview : vb 2010 express + mysql server 5 + odbc connector
1. I am able to connect database successfully. I am using arraylist to set data.
& also i m getting till it set to dataview (Object name )
2. Till now i am not added any column name in datagridview property setting .[add/remove column]
My code

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If mConnection Is Nothing Then mConnection = New Odbc.OdbcConnection
        ' check if the connection is already open
        If mConnection.State = ConnectionState.Open Then mConnection.Close()
        ' open the connection to the database
        ' string to store the connection string
        Dim connectionstring As String
        Dim username As String = "root" 'CHANGE THIS
        Dim password As String = "root" 'CHANGE THIS
        Dim server As String  '"localhost" or "127.0.0.1" or "192.164.215.243" or "www.google.com" or "www.palomasoaps.com" or "Bill.apollo.net"
        Dim driver As String = "{MySQL ODBC 5.1 Driver}"
        Dim database As String = "studentproject"
        ' the connection string object
        server = "localhost"
        connectionstring = "Driver=" & driver & "; Server=" & server & "; User=" & username & "; Password=" & password & ";Database=" & database & ";"
        ' try to open the connection
        mConnection.ConnectionString = connectionstring
        Try
            mConnection.Open()



        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
        ' check the state to see if it opened correctly
        If mConnection.State <> ConnectionState.Open Then
            MessageBox.Show("Error Opening Connection")
        ElseIf mConnection.State = ConnectionState.Open Then
       
           

        End If

    End Sub




 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If mConnection.State <> ConnectionState.Open Then Exit Sub
        Dim sqlCommand As New Odbc.OdbcCommand
        Dim result As Odbc.OdbcDataReader
        Dim ds As Odbc.OdbcDataAdapter
        sqlCommand.Connection = mConnection
        sqlCommand.CommandText = "select msg_id from  messages"
        result = sqlCommand.ExecuteReader
        Dim dataView As New DataGridView()
        Dim lstRecords As New ArrayList()
        lstRecords.Clear()
        While (result.Read())
        lstRecords.Add(result("msg_id"))
        End While
        dataView.DataSource = ds1.DefaultViewManager
        dataView.DataMember = "messages"
        result = Nothing
        sqlCommand.Dispose()
        sqlCommand = Nothing
    End Sub

please help me out. I dont know what to do now. Just searching

Edited 5 Years Ago by Nick Evan: Fixed tags and moved thread

You're using VB.Net.
This is VB6. I don't have much experience with VB.NET. You might try on that forum.

This article has been dead for over six months. Start a new discussion instead.