?
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
Medium Priority
?
105 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 34

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 34

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
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 

Author Comment

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

Accepted Solution

by:
Norie earned 2000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 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