Link to home
Start Free TrialLog in
Avatar of tang kiat seong
tang kiat seong

asked on

i want to change the ADD_CAR table available to true and import the data to RETURN table. now the problem is the data can import into RETURN table but the ADD_CAR table the available still not change

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

        If ComboBox1.Text = "" Or TextBox3.Text = "" Or TextBox2.Text = "" Or TextBox1.Text = "" Or TextBox4.Text = "" Or daytxt.Text = "" Or totalbox.Text = "" Or TextBox5.Text = "" Then
            MessageBox.Show(" Please fill in all the information", "Information", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
        Else
            Try

                myConnToAccess = New OleDbConnection("provider=microsoft.ACE.oledb.12.0; data source=C:\Users\User\Desktop\FYP\VB\Database.accdb")
                myConnToAccess.Open()
                Dim command As String
                Dim command1 As String
                command = "INSERT INTO RETURN (Username,CarName,Reg_ID,Plate_Number,Days,Pick_Up_Date,Return_Date,Total_Amount) VALUES (Username,CarName,Reg_ID,Plate_Number,Days,Pick_Up_Date,Return_Date,Total_Amount)"
                command1 = "UPDATE ADD_CAR SET Avaliable = True WHERE Reg_ID = '" & TextBox5.Text & "' "
                Dim cmd As OleDb.OleDbCommand
                Dim cmd1 As OleDb.OleDbCommand
                cmd = New OleDb.OleDbCommand(command, myConnToAccess)
                cmd1 = New OleDb.OleDbCommand(command1, myConnToAccess)

                cmd.Parameters.AddWithValue("Username", ComboBox1.Text)
                cmd.Parameters.AddWithValue("CarName", TextBox1.Text)
                cmd.Parameters.AddWithValue("Reg_ID", TextBox5.Text)
                cmd.Parameters.AddWithValue("Plate_Number", TextBox4.Text)
                cmd.Parameters.AddWithValue("Days", daytxt.Text)
                cmd.Parameters.AddWithValue("Pick_Up_Date", TextBox2.Text)
                cmd.Parameters.AddWithValue("Return_Date", TextBox3.Text)
                cmd.Parameters.AddWithValue("Total_Amount", totalbox.Text)

                cmd.ExecuteNonQuery()
                cmd1.ExecuteNonQuery()

            Catch exceptionObject As Exception
                MessageBox.Show(exceptionObject.Message)
            Finally
                myConnToAccess.Close()
                MessageBox.Show(" Return Successful!", " Register Information ", MessageBoxButtons.OK, MessageBoxIcon.Information)

            End Try
        End If
    End Sub

Open in new window

Capture.JPG
Capture.JPG
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tang kiat seong
tang kiat seong

ASKER

@Ryan Chong: no i just wan to update the available only
no i just wan to update the available only
ok, so try to put a break point after the line:
command1 = "UPDATE ADD_CAR SET Avaliable = 1 WHERE Reg_ID = '" & TextBox5.Text & "' "

and then put the command1 into a watch. and see what's its value?

copy this statement and run it in your Access database and see if any record was being updated?
@Ryan Chong how to use a break point or watch? i never use before
how to use a break point or watch? i never use before

check these out:

Using Breakpoints
https://msdn.microsoft.com/en-us/library/5557y8b4.aspx

Watch and QuickWatch Windows
https://msdn.microsoft.com/en-us/library/0taedcee.aspx
still cannot~~~
that code i use why it can work on my other form?
well, some times we can't simply debug for you with limited information.

or you can upload your project files here so that we can diagnose your issue.