I have 3 tables in database.mdf(created in Visual Basic local)Customers,Orders,Products
I am trying to insert a row in Orders table using textboxes.The new row appears in DataGrid view but does not show in Show Table Data in Database Explorer.
My insert Query in TableAdapter is
INSERT INTO Orders
(Customer_ID, Product_ID, OrderDate, TotalPrice, Quantity, PaidBy)
VALUES (@Customer_ID,@Product_ID,@Orderdate,@TotalPrice,@Quantity,@PaidBy);
SELECT SCOPE_IDENTITY()
Order_ID is the primary key and autoincrement.
My UpdateQuery
UPDATE Orders
SET Customer_ID = @Customer_ID, Product_ID = @Product_ID, OrderDate = @OrderDate, TotalPrice = @TotalPrice, Quantity = @Quantity, PaidBy = @PaidBy;
SELECT SCOPE_IDENTITY()
Button Click Code looks like this:
Private Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
Me.OrdersTableAdapter.InsertQuery(CShort(txtCustomerID.Text), txtProductID.Text, Today(),
CDec(txtPrice.Text), CShort(txtQuantity.Text), txtPaidBy.Text)
Me.OrdersTableAdapter.Fill(Me.CustomerOrderDataSet.Orders)
Me.OrdersTableAdapter.UpdateQuery(CShort(txtCustomerID.Text), txtProductID.Text, Today(),
CDec(txtPrice.Text), CShort(txtQuantity.Text), txtPaidBy.Text)
End Sub
ExecuteMode is Scalar
Copy to Output Directory is Copy if newer
What is it that I am missing?Why it is not adding row to database?
I really appreciate any help.
I am trying to insert a row in Orders table using textboxes.The new row appears in DataGrid view but does not show in Show Table Data in Database Explorer.
My insert Query in TableAdapter is
INSERT INTO Orders
(Customer_ID, Product_ID, OrderDate, TotalPrice, Quantity, PaidBy)
VALUES (@Customer_ID,@Product_ID,@Orderdate,@TotalPrice,@Quantity,@PaidBy);
SELECT SCOPE_IDENTITY()
Order_ID is the primary key and autoincrement.
My UpdateQuery
UPDATE Orders
SET Customer_ID = @Customer_ID, Product_ID = @Product_ID, OrderDate = @OrderDate, TotalPrice = @TotalPrice, Quantity = @Quantity, PaidBy = @PaidBy;
SELECT SCOPE_IDENTITY()
Button Click Code looks like this:
Private Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
Me.OrdersTableAdapter.InsertQuery(CShort(txtCustomerID.Text), txtProductID.Text, Today(),
CDec(txtPrice.Text), CShort(txtQuantity.Text), txtPaidBy.Text)
Me.OrdersTableAdapter.Fill(Me.CustomerOrderDataSet.Orders)
Me.OrdersTableAdapter.UpdateQuery(CShort(txtCustomerID.Text), txtProductID.Text, Today(),
CDec(txtPrice.Text), CShort(txtQuantity.Text), txtPaidBy.Text)
End Sub
ExecuteMode is Scalar
Copy to Output Directory is Copy if newer
What is it that I am missing?Why it is not adding row to database?
I really appreciate any help.