hi,
can i ask how do i insert my records from my textbox to specific column name of my table

IsConnected("Insert into products values(" & _
                            Me.TextBox1.Text & ",'" & _
                            Me.TextBox2.Text & "','" & _
                            Me.TextBox3.Text & "','" & _
                            Me.TextBox4.Text & "','" & _
                            Me.TextBox5.Text & "','" & _
                            Me.TextBox6.Text & "')", True)

here i used this code inserting it work, but now im going to insert records into specific column name like textbox1.text = id textbox2.text = lname like that.. here is my module code

Imports MySql.Data.MySqlClient
Module Module1
    Public myConn As New MySqlConnection
    Public myCmd As New MySqlCommand
    Public myDR As MySqlDataReader
    Public frUpdate As Boolean



    Public Function IsConnected(ByVal strQry As String, ByVal ver As Boolean)
        Try

            If myConn.State = ConnectionState.Open Then myConn.Close()
            myConn.ConnectionString = "server=localhost; user id=root; password=password; database=pms;"
            myConn.Open()

            myCmd.CommandText = strQry
            myCmd.Connection = myConn

            If ver = False Then
                myDR = myCmd.ExecuteReader() 'Pra basahin ung query


            Else
                myCmd.ExecuteNonQuery() 'Pra iupdate ung query

            End If

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
        End Try

    End Function

can you help me?

Build and insert string from your textboxes;

dim sSQL
sSQL = "VALUES (" & Me.TextBox1.Text & ",'" & Me.TextBox2.Text & "','" & Me.TextBox3.Text & "','" & Me.TextBox4.Text & "','" & Me.TextBox5.Text & "','" & Me.TextBox6.Text & "')", True)"

change the INSERT to "INSERT INTO PRODUCTS (product1,product2,product3,product4,product5,product6) " & sSQL

The format for an INSERT is INSERT INTO (x,y,z) VALUES(1,2,3)

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