Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 4342
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 3, 20222022-06-03T17:47:11+00:00 2022-06-03T17:47:11+00:00

TRANSFER TABLE INFORMATION IN DIN DATABASE IN LOCAL MYSQL to A remote MYSQL Database VB.NET

  • 0

[ad_1]



Want to improve this question? Add details and clarify the problem by editing this post.



I have an application in VB.net with BD in Mysql local with Xampp, what I want to do is to pass only the records of the table that have as a state “PENDING” to another similar table but in a remote MYSQL of my hosting, I have managed to do it with this code but I have obtained some errors from time to time when the application “READING FROM THE STREAM HAS FAILED” and other times “UNABLE MYSQLHOST” is executed and it omits me in insert a record.

Imports System.Data.OleDb
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class Form1
    Public cm As MySqlConnection
    Public CadenaConexion As String
    Dim estado As Boolean = True
    Dim rcvdata As String = ""
    Dim contador As Integer = 0
    Dim contar_datos, num As Integer
    Dim CONDICION As String
    Dim detalle, observacion, estudiantes, registros, DECO, Nombres, Apellidos, Grado, Seccion, Dni As String
    Dim indice, tipo, contenido, fechae, fechac, lugar, id, Nombre, horaingreso, horasalida, fecha, mes, año, celular, reportado As String
 Private Sub btnincidencias_Click(sender As Object, e As EventArgs) Handles btnincidencias.Click
        Dim i As Integer
        num = Val(DataGridincidencias.RowCount - 1)

        For i = 0 To num - 1
            id = DataGridincidencias.Rows(i).Cells.Item(0).Value.ToString()
            Dni = DataGridincidencias.Rows(i).Cells.Item(1).Value.ToString()
            Apellidos = DataGridincidencias.Rows(i).Cells.Item(2).Value.ToString()
            Nombres = DataGridincidencias.Rows(i).Cells.Item(3).Value.ToString()
            fecha = DataGridincidencias.Rows(i).Cells.Item(4).Value.ToString()
            Grado = DataGridincidencias.Rows(i).Cells.Item(5).Value.ToString()
            Seccion = DataGridincidencias.Rows(i).Cells.Item(6).Value.ToString()
            observacion = DataGridincidencias.Rows(i).Cells.Item(7).Value.ToString()
            detalle = DataGridincidencias.Rows(i).Cells.Item(8).Value.ToString()
            reportado = DataGridincidencias.Rows(i).Cells.Item(9).Value.ToString()
            celular = DataGridincidencias.Rows(i).Cells.Item(10).Value.ToString()

            Try
                Dim iReturn As Boolean
                Using SQLConnection As New MySqlConnection("Data Source=162.214.204.218; initial catalog=carmelin_bdquinto; user id=carmelin_ricardo;password=Nevermind33.;")
                    Using sqlCommand As New MySqlCommand()
                        With sqlCommand
                            .CommandText = "INSERT INTO INCIDENCIAS (`DNI`,`APELLIDOS`,`NOMBRES`,`FECHA`,`GRADO`,`SECCION`,`OBSERVACION`,`DETALLE`,`REPORTADO`,`TELEFONO`) values (@DNI,@APELLIDOS,@NOMBRES,@FECHA,@GRADO,@SECCION,@OBSERVACION,@DETALLE,@REPORTADO,@TELEFONO)"

                            .Connection = SQLConnection
                            .CommandType = CommandType.Text
                            .Parameters.AddWithValue("@DNI", Dni.ToString)
                            .Parameters.AddWithValue("@APELLIDOS", Apellidos.ToString)
                            .Parameters.AddWithValue("@NOMBRES", Nombres.ToString)
                            .Parameters.AddWithValue("@FECHA", fecha.ToString)
                            .Parameters.AddWithValue("@GRADO", Grado.ToString)
                            .Parameters.AddWithValue("@SECCION", Seccion.ToString)
                            .Parameters.AddWithValue("@OBSERVACION", observacion.ToString)
                            .Parameters.AddWithValue("@DETALLE", detalle.ToString)
                            .Parameters.AddWithValue("@REPORTADO", "REPORTADO")
                            .Parameters.AddWithValue("@TELEFONO", celular.ToString)

                        End With
                        Try
                            SQLConnection.Open()
                            sqlCommand.ExecuteNonQuery()
                            iReturn = True

                            ''boton 3
                            Using _conn As New MySqlConnection("datasource=127.0.0.1;port=3306;username=root;password=;database=bdquinto;")
                                Using _comm As New MySqlCommand()
                                    With _comm
                                        .Connection = _conn
                                        .CommandText = "UPDATE INCIDENCIAS SET REPORTADO = @Reportado WHERE id=@Cod"
                                        .CommandType = CommandType.Text
                                        .Parameters.AddWithValue("@Reportado", "REPORTADO")
                                        .Parameters.AddWithValue("@Cod", DataGridincidencias.Rows(i).Cells.Item(0).Value.ToString())

                                    End With
                                    Try
                                        _conn.Open()
                                        _comm.ExecuteNonQuery()

                                    Catch ex As MySqlException
                                        MsgBox(ex.Message.ToString())
                                    End Try
                                End Using
                            End Using
                        Catch ex As MySqlException
                            MsgBox(ex.Message.ToString)
                            iReturn = False
                        Finally
                            SQLConnection.Close()
                        End Try
                    End Using
                End Using

            Catch ex As Exception
            End Try

        Next i
        MsgBox("Se sincronizo con exito todos los registros")

    End Sub

I AM A NEWBIE TO THIS PLEASE HELP ME WITH THIS PROBLEM, THANK YOU VERY MUCH IN ADVANCE

[ad_2]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 8087 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1871 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1957 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.