Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

error In the codes to enter data through form

$
0
0

Dear All

Dim cn As New OleDbConnection
        Dim cmd As New OleDbCommand
        Dim sql As String

        cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.15.0;data source = Sample.accdb"
        cmd.Connection = cn
        cn.Open()



        Dim OrderID As Integer
        Integer.TryParse(OrderIDTextBox.Text, OrderID)
        Dim CustID As Integer
        Integer.TryParse(CustIDTextBox1.Text, CustID)

        sql = "(INSERT INTO ORDERS values('" & OrderIDTextBox.Text & "','" & CustIDTextBox1.Text & "', '" & ProductIDTextBox.Text & "','" & UnitPriceTextBox.Text & "','" & QuantityTextBox.Text & "','" & DiscountTextBox.Text & "'))"

        cmd.Parameters.AddWithValue("@OrderID", OrderID)
        cmd.Parameters.AddWithValue("@CustID", CustID)
        cmd.Parameters.AddWithValue("@ProductID", ProductIDTextBox.Text)
        cmd.Parameters.AddWithValue("@UnitPrice", UnitPriceTextBox.Text)
        cmd.Parameters.AddWithValue("@Quantity", QuantityTextBox.Text)
        cmd.Parameters.AddWithValue("@Discount", DiscountTextBox.Text)

        cmd = New OleDbCommand(sql, cn)
        cmd.ExecuteNonQuery()
        MessageBox.Show("Inserted Values Successfully")
        cn.Close()

getting error as data mismatch OrderID and CustID getting 0(Zero) even after entering 1 in OrderIDTextBox & custIDtextBox

whats wrong in codes

Sunil




Viewing all articles
Browse latest Browse all 2535

Trending Articles



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