Quantcast
Viewing all articles
Browse latest Browse all 27072

VS 2010 Listview save data in MySQL database

Hello to all!

I appreciate the invitation to the club vbforums! :wave:

I'm starting with visual studio 2010, and I have a doubt that I could possibly help ..
I have my listview and I want to save the data to a mysql table.
My code is:

Code:

        Dim strSQL As String
        Dim lvItem As ListViewItem

        Dim connstring As String = "Data Source=192.168.1.5;Database=clc;User ID=MXOGUZ;Password=***;"
        Dim conn As New MySqlConnection(connstring)
        Dim cmd As New MySqlCommand
        conn.Open()
        For Each lvItem In ListView1.Items
            strSQL = "INSERT INTO resultado SET " & _
                    "ID_EMPLEADO='" & lvItem.SubItems(0).Text & "'," & _
                    "APELLIDO_1='" & lvItem.SubItems(1).Text & "'," & _
                    "APELLIDO_2='" & lvItem.SubItems(2).Text & "'"

            cmd.CommandText = strSQL
            cmd.ExecuteNonQuery()
        Next
        conn.Close()
    End Sub

but the problem is in the:
Code:

  cmd.ExecuteNonQuery()
I read in the forums is possibly because it exceeds the capacity of characters.
But my table is VARCHAR (255) in all fields,
Does anyone who could help me?

Thank you!:thumb:
Best Regards!!

Viewing all articles
Browse latest Browse all 27072


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>