datagridview not refreshing

nvargas

New member
Joined
May 16, 2007
Messages
2
Location
Managua, Nicaragua
Programming Experience
Beginner
Hi,

I'm building this app that has to take data from two db engines, Pervasive and MySQL, process it and write to a MySQL database.

I did the processing part and works just fine.

The problem is that I bound a datagridview to the resulting table, so, as soon as you load the form, you can see the processed data, if there is any. After the processing, I need to refresh the datagridview.

Tried tons of things and googled for it, to no avail. I created a separate button to do the refreshing, and it still doesn't work.

This is the code for my button:

VB.NET:
        ' Grabar y actualizar registros
        Dim stConexion As String = "Driver={MySQL ODBC 3.51 Driver};Server=x.x.x.x;Port=3306;Database=SAIRI;User=xxxxx;Password=xxxxxx;Option=3;"
        Dim dbMysql As New OdbcDataAdapter
        Dim connMysql As New OdbcConnection(stConexion)
        Dim commMysql As New OdbcCommand("SELECT idElemento, txtJournalBatchNumber, txtRUC, txtCedula,txtDocumentNumber, txtNumeroDocumento, txtNombre,  txtSubTotal, txtRetencionIR, txtMontoIVA, datFechaEmision, txtDescripcionPago, datApplyDate, txtCuentaGasto,txtDescripcionCuenta FROM tblTemporalProcesamiento ORDER BY datApplyDate,txtNombre", connMysql)
        Dim dsMysql As New DataSet

        dbMysql.SelectCommand = commMysql
        dbMysql.SelectCommand.CommandType = CommandType.Text
        dbMysql.Fill(dsMysql)
        Try
            Me.progressStatusBar.Step = 50
            DataGridTemporal.DataSource = dsMysql
            Me.progressStatusBar.Step = 100
        Catch errMySQL As System.Exception
            System.Windows.Forms.MessageBox.Show(errMySQL.Message)
        End Try

        dsMysql = Nothing
        commMysql = Nothing
        connMysql = Nothing
        dbMysql = Nothing

Any ideas?
 
Well, the thread had no answers, but found the problem, so maybe it will be helpful to someone else. Check the bold portion for the missing instruction that made it work.

VB.NET:
Dim stConexion As String = "Driver={MySQL ODBC 3.51 Driver};Server=192.168.0.201;Port=3306;Database=SAIRI;User=sairi;Password=sairi;Option=3;"
        Dim dbMysql As New OdbcDataAdapter
        Dim connMysql As New OdbcConnection(stConexion)
        Dim commMysql As New OdbcCommand("SELECT idElemento, txtJournalBatchNumber, txtRUC, txtCedula,txtDocumentNumber, txtNumeroDocumento, txtNombre,  txtSubTotal, txtRetencionIR, txtMontoIVA, datFechaEmision, txtDescripcionPago, datApplyDate, txtCuentaGasto,txtDescripcionCuenta FROM tblTemporalProcesamiento ORDER BY datApplyDate,txtNombre", connMysql)
        Dim dsMysql As New DataSet

        dbMysql.SelectCommand = commMysql
        dbMysql.SelectCommand.CommandType = CommandType.Text
        dbMysql.Fill(dsMysql)
        Try
            Me.progressStatusBar.Step = 50
            [B]DataGridTemporal.DataSource = dsMysql.Tables(0).DefaultView[/B]
            Me.progressStatusBar.Step = 100
        Catch errMySQL As System.Exception
            System.Windows.Forms.MessageBox.Show(errMySQL.Message)
        End Try

        dsMysql = Nothing
        commMysql = Nothing
        connMysql = Nothing
        dbMysql = Nothing

Found it while reading this
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=753872&SiteID=1
 
Back
Top