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
100 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account 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 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

726 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