Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have created a program to add a record to a database (to the table "Orders"). I have added an OleDB database using Visual Studio's connection wizard. The database was originally created in Microsoft Access before adding it to Visual Studio.

This is the code I have used.

The problem is that the records do not get updated to the database, even though the code runs successfully.

Please help me out. Many Thanks

VB
Private Sub createRecordInDatabase(productID As String, Quantity As String, PrivilegeCardHolder As Integer, privilegeCardNumber As String, paymentMethod As String, totalpayable As String, customerName As String, paymentDetails As String)
        Dim rw As DataRow
        rw = Beeme_Laptop_StoreDataSet.Tables(0).NewRow
        rw.Item("Product_ID") = productID
        rw.Item("Quantity") = Quantity
        rw.Item("Order_Date") = Now.Date.ToShortDateString
        rw.Item("Order_Time") = Now.TimeOfDay.ToString
        rw.Item("PrivilegeCardHolder?") = PrivilegeCardHolder
        rw.Item("PrivilegeCardNumber") = privilegeCardNumber
        rw.Item("Payment_Method") = paymentMethod
        rw.Item("Total_Payable") = totalpayable
        rw.Item("Payment_Made") = 0
        rw.Item("Customer_Name") = customerName
        rw.Item("Payment_Details") = paymentDetails

        Beeme_Laptop_StoreDataSet.Tables(0).Rows.Add(rw)
        OrdersTableAdapter.Update(Beeme_Laptop_StoreDataSet)

        MsgBox("records updated")
    End Sub
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900