Solved

i want to booking the car. how to change the available to no and transfer the data into booking table

Posted on 2016-10-23
6
92 Views
Last Modified: 2016-11-09
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If ComboBox1.Text = "" Or ComboBox2.Text = "" Or TextBox1.Text = "" Or TextBox4.Text = "" Or rentbox.Text = "" Or totalbox.Text = "" Or daytxt.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
                command = "INSERT INTO BOOKING (Username,CarName,Colour,Plate_Number,Rent_Price,Days,Pick_Up_Date,Return_Date,Total_Amount) VALUES (Username,CarName,Colour,Plate_Number,Rent_Price,Days,Pick_Up_Date,Return_Date,Total_Amount)"
                Dim cmd As OleDb.OleDbCommand
                cmd = New OleDb.OleDbCommand(command, myConnToAccess)
                cmd.Parameters.AddWithValue("Username", ComboBox1.Text)
                cmd.Parameters.AddWithValue("CarName", ComboBox2.Text)
                cmd.Parameters.AddWithValue("Colour", TextBox1.Text)
                cmd.Parameters.AddWithValue("Plate_Number", TextBox4.Text)
                cmd.Parameters.AddWithValue("Rent_Price", rentbox.Text)
                cmd.Parameters.AddWithValue("Days", daytxt.Text)
                cmd.Parameters.AddWithValue("Pick_Up_Date", DateTimePicker1.Value.Date)
                cmd.Parameters.AddWithValue("Return_Date", DateTimePicker2.Value.Date)
                cmd.Parameters.AddWithValue("Total_Amount", totalbox.Text)

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

            End Try
        End If
    End SubCapture5.JPG
0
Comment
Question by:tang kiat seong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 41855961
To change Available to No you'll need an UPDATE query.

What's the name of the table with the Available field in it?

What's it's primary key? Is that primary key available on the form?
0
 

Author Comment

by:tang kiat seong
ID: 41856056
@Norie Reg_ID is the primary key.
what i want is when the car in booking the available change to not
0
 
LVL 33

Expert Comment

by:Norie
ID: 41856058
You would need an UPDATE query like this then,
command = "UPDATE [i]yourtablename[/i] SET Available = 0 WHERE Reg_ID = '" & txtRegID.Text & "';"

Open in new window

where Reg_ID is coming from the textbox txtRegID.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

by:tang kiat seong
ID: 41856098
if in the return car also use same command?
0
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 41856107
Not sure what you mean.

If you want to change Available to Yes when the car is returned you would use something like this.
command = "UPDATE [i]yourtablename[/i] SET Available = 1 WHERE Reg_ID = '" & txtRegID.Text & "';"

Open in new window

0
 

Author Comment

by:tang kiat seong
ID: 41880435
@Norie about the return table i using same code but didn't work...
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question