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 "" or "" or "" or "" or ""
        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

        Catch ex As Exception
        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()
        While (result.Read())
        End While
        dataView.DataSource = ds1.DefaultViewManager
        dataView.DataMember = "messages"
        result = Nothing
        sqlCommand = Nothing
    End Sub

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

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

Okey No probs .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.