MYSQL returns MAXIMUM CONNECTION POOL error when I try to add more then hundred entries in one transaction

I have stock database application so where user enter all the items to a datagrid which is added to database later, but whenever the items are more than 100 items it returns error:

Error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

Here is the code:

 For Each row As DataGridViewRow In DGV_ITEMS.Rows

        If row.IsNewRow = False Then

            Dim ITEM_CODE_VAL As Double = row.Cells(1).Value
            Dim ITEM_QUANTITY_VAL = row.Cells(2).Value
            Dim ITEM_NAME_VAL = row.Cells(3).Value
            Dim ITEM_PRICE_VAL = row.Cells(4).Value
            Dim ITEM_DATE_VAL = row.Cells(5).Value

            'FOR CHECK IF SUPPLIER ALL READY EXISTS
            Dim CON1 As New MySqlConnection("server=localhost; username=root; password=pwd; database=airtech_db;")
            Dim CMD1 As New MySqlCommand("SELECT * FROM `STOCK` where `ITEM_CODE`='" & row.Cells(1).Value & "';", con1)
            Dim dt1 As New DataTable
            Dim DR1 As MySqlDataReader
            CON1.Open()
            dt1.Clear()
            With dt1
                DR1 = CMD1.ExecuteReader
                DR1.Read()
                If DR1.HasRows = True Then
                    'MsgBox("Item already exists")
                    Call ADD_DATA_TO_EXISTING_RECORD(ITEM_CODE_VAL, ITEM_QUANTITY_VAL)
                    CON1.Close()
                Else
                    'Using con As New MySqlConnection(constring)
                    Using cmd As New MySqlCommand("Insert into `stock` values(null,@ITEM_CODE,@ITEM_NAME,@ITEM_PRICE,@ITEM_QUANTITY,@SALE_PRICE,@STOCK_DATE,'N/A');", con)
                        Try
                            Dim CON As New MySqlConnection("server=localhost; username=root; password=pwd; database=airtech_db;")
                            con.Open()
                            cmd.Parameters.AddWithValue("@ITEM_CODE", row.Cells(1).Value)
                            cmd.Parameters.AddWithValue("@ITEM_NAME", row.Cells(3).Value)
                            cmd.Parameters.AddWithValue("@ITEM_PRICE", row.Cells(4).Value)
                            cmd.Parameters.AddWithValue("@ITEM_QUANTITY", row.Cells(2).Value)
                            cmd.Parameters.AddWithValue("@SALE_PRICE", row.Cells(5).Value)
                            cmd.Parameters.AddWithValue("@STOCK_DATE", Date.Now.ToString("yyyy-MM-dd"))
                            cmd.ExecuteNonQuery()
                        Finally
                            con.Close()
                        End Try

                    End Using
                    'End Using

                End If
            End With
        End If
    Next

Answer

if a query is made being in the loop, move the connection string out of the loop let the command and datareaders do the work inside the loop

e.g

Using con As New MySqlConnection(constring)
        con.Open()
        'any for Loop you want to run

        Using cmd As New MySqlCommand("Insert into `stock` values(null,@ITEM_CODE,@ITEM_NAME,@ITEM_PRICE,@ITEM_QUANTITY,@SALE_PRICE,@STOCK_DATE,'N/A');", con)
            cmd.Parameters.AddWithValue("@ITEM_CODE", row.Cells(1).Value)
            cmd.Parameters.AddWithValue("@ITEM_NAME", row.Cells(3).Value)
            cmd.Parameters.AddWithValue("@ITEM_PRICE", row.Cells(4).Value)
            cmd.Parameters.AddWithValue("@ITEM_QUANTITY", row.Cells(2).Value)
            cmd.Parameters.AddWithValue("@SALE_PRICE", row.Cells(5).Value)
            cmd.Parameters.AddWithValue("@STOCK_DATE", Date.Now.ToString("yyyy-MM-dd"))
            cmd.ExecuteNonQuery()
        End Using
    End Using
    Next
    con.Close()