0

I checked my spellings and everything for so many times already
Here's the code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If Not cnn.State = ConnectionState.Open Then
            'open connection if it is not yet open
            cnn.Open()
        End If

        cmd.Connection = cnn
        'check whether add new or update

        'add new 
        'add data to table
        cmd.CommandText = " INSERT INTO JandKstock( Product_Name, Stock, Sold_Item, Stock_Remaining, Unit_Price, Quantity_Price, Total_Sales)" & _
                          " VALUES(" & Me.Product_NameTextBox.Text & ",'" & Me.StockTextBox.Text & "','" & Me.Sold_ItemTextBox.Text & "','" & Me.Stock_RemainingTextBox.Text & "','" & Me.Unit_PriceTextBox.Text & "','" & Me.Quantity_PriceTextBox.Text & "','" & Me.Total_SalesTextBox.Text & "')"

        cmd.ExecuteNonQuery()

        'refresh data in list
        RefreshData()
        'clear form
        Me.btnClear.PerformClick()

        'close connection
        cnn.Close()
    End Sub
2
Contributors
1
Reply
6
Views
1 Year
Discussion Span
Last Post by hericles
0

You're not quoting the first value, Me.Product_NameTextBox. And you are quoting both price inputs. Is that correct? I would have expected them to be decimals/currency inputs.
Also, use parameters to insert variables into command text.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.