'Data not sending to Access database using VB.NET

I am having trouble with the following code; it is not sending to the database

I have included all code in case there is a problem elsewhere that is effecting the sending of data to the database

The code is not throwing any errors when running or when btnBook is clicked

Imports System.Data.OleDb
Public Class frmBookRoom
    Private DB As New DBControl
    Private DBCon As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" &
                                         "Data Source=|DataDirectory|\NewHotel.mdb;")

    Private Function NotEmpty(text As String) As Boolean
        Return Not String.IsNullOrEmpty(text)
    End Function

    Private Sub AddBooking()
        'Add parameters
        DB.AddParam("@RoomType", cbxRoomType.Text)
        DB.AddParam("@CheckIn", txtCheckIn.Text)
        DB.AddParam("@Checkout", txtCheckOut.Text)
        DB.AddParam("@NoNights", txtNights.Text)
        DB.AddParam("@Adults", txtAdults.Text)
        DB.AddParam("@Children", txtChildren.Text)
        DB.AddParam("@FullName", txtName.Text)
        DB.AddParam("@Revenue", txtPrice.Text)
        DB.AddParam("@DateBooked", Date.Today)

        'Execute insert command
        DB.ExecQuery("INSERT INTO tblRoomBookings([RoomType], [CheckIn], [Checkout], [NoNights], [Adults], [Children], [FullName], [Revenue], [DateBooked])" &
                         "VALUES(@RoomType, @CheckIn, @Checkout, @NoNiights, @Adults, @Children, @FullName, @Revenue, @DateBooked)")

        'Report and abort on errors
        If Not String.IsNullOrEmpty(DB.Exception) Then MsgBox(DB.Exception) : Exit Sub
        DBCon.Close()
    End Sub

    Private Sub btnBook_Click(sender As Object, e As EventArgs) Handles btnBook.Click
        'Perform the sub routine AddBooking
        AddBooking()

        'Clear all the text boxes ready for the next entry
        cbxRoomType.Text = Nothing
        txtCheckIn.Clear()
        txtCheckOut.Clear()
        txtNights.Clear()
        txtAdults.Text = "2"
        txtChildren.Text = "0"
        txtName.Clear()
        txtPrice.Clear()
    End Sub

    Private Sub frmBookRoom_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'Open connection to the database
        If DBCon.State = ConnectionState.Closed Then DBCon.Open() : Exit Sub
    End Sub

    Private Sub frmBookRoom_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        'Calendar only displays dates from today forward
        MonthCalendar1.MinDate = Date.Today
    End Sub

    Private Sub btnLessAdults_Click(sender As Object, e As EventArgs) Handles btnLessAdults.Click
        'Take one away from the number of adults
        txtAdults.Text -= 1
        'Don't allow the number to be less than one
        If txtAdults.Text <= 1 Then txtAdults.Text = 1
    End Sub

    Private Sub btnMoreAdults_Click(sender As Object, e As EventArgs) Handles btnMoreAdults.Click
        'Add one to the number of adults
        txtAdults.Text += 1
    End Sub

    Private Sub btnLessChildren_Click(sender As Object, e As EventArgs) Handles btnLessChildren.Click
        'Take one away from the number of children
        txtChildren.Text -= 1
        'Don't allow the number of children to be less than zero
        If txtChildren.Text <= 0 Then txtChildren.Text = 0
    End Sub

    Private Sub btnMoreChildren_Click(sender As Object, e As EventArgs) Handles btnMoreChildren.Click
        'Add one to the number of children
        txtChildren.Text += 1
    End Sub

    Private Sub btnPrice_Click(sender As Object, e As EventArgs) Handles btnPrice.Click
        Dim Nights As Integer
        Nights = txtNights.Text
        'Calculation to work out the total price of the stay
        If cbxRoomType.Text = "single" Then
            If CDbl("0" + txtNights.Text = 1) Then
                txtPrice.Text = "£99.99"
            Else
                txtPrice.Text = "£" & Format(99.99 * (1.2 ^ Nights), "0.00")
            End If
        End If

        If cbxRoomType.Text = "twin" Then
            If CDbl("0" + txtNights.Text = 1) Then
                txtPrice.Text = "£124.99"
            Else
                txtPrice.Text = "£" & Format(124.99 * (1.2 ^ Nights), "0.00")
            End If
        End If

        If cbxRoomType.Text = "double" Then
            If CDbl("0" + txtNights.Text = 1) Then
                txtPrice.Text = "£149.99"
            Else
                txtPrice.Text = "£" & Format(149.99 * (1.2 ^ Nights), "0.00")
            End If
        End If

        If cbxRoomType.Text = "double double" Then
            If CDbl("0" + txtNights.Text = 1) Then
                txtPrice.Text = "£164.99"
            Else
                txtPrice.Text = "£" & Format(164.99 * (1.2 ^ Nights), "0.00")
            End If
        End If

        If cbxRoomType.Text = "mini suite" Then
            If CDbl("0" + txtNights.Text = 1) Then
                txtPrice.Text = "£250"
            Else
                txtPrice.Text = "£" & Format(250 * (1.2 ^ Nights), "0.00")
            End If
        End If

        If cbxRoomType.Text = "master suite" Then
            If CDbl("0" + txtNights.Text = 1) Then
                txtPrice.Text = "£275"
            Else
                txtPrice.Text = "£" & Format(275 * (1.2 ^ Nights), "0.00")
            End If
        End If


        btnBook.Enabled = True
    End Sub

    Private Sub MonthCalendar1_DateSelected(sender As Object, e As DateRangeEventArgs) Handles MonthCalendar1.DateSelected
        'Automatically have the first and last date put into the corresponding textboxes
        txtCheckIn.Text = MonthCalendar1.SelectionRange.Start.Date.ToString("dd/MM/yyyy")
        txtCheckOut.Text = MonthCalendar1.SelectionRange.End.Date.ToString("dd/MM/yyyy")
    End Sub

    Private Sub cbxRoomType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbxRoomType.SelectedIndexChanged, txtCheckIn.TextChanged, txtCheckOut.TextChanged, txtNights.TextChanged, txtName.TextChanged
        'Enable buttons for booking and seeingg the price when the length of stay is entered
        If Not String.IsNullOrWhiteSpace(txtName.Text) Then
            btnPrice.Enabled = True
        End If
    End Sub

    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
        'Clear the form
        cbxRoomType.Text = Nothing
        txtCheckIn.Clear()
        txtCheckOut.Clear()
        txtNights.Clear()
        txtAdults.Text = "2"
        txtChildren.Text = "0"
        txtName.Clear()
        txtPrice.Clear()
    End Sub

    Private Sub txtName_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtName.KeyPress
        'Only allow entry of letters
        If Char.IsNumber(e.KeyChar) = True Then
            e.Handled = True
        ElseIf Char.IsPunctuation(e.KeyChar) = True Then
            e.Handled = True
        End If
    End Sub

    Private Sub btnViewEditBookings_Click(sender As Object, e As EventArgs) Handles btnViewEditBookings.Click
        'Display View and Edit Bookings form
        frmViewEditBookings.Show()
    End Sub

    Private Sub txtNights_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtNights.KeyPress
        'Only allow entry of numbers
        If Char.IsLetter(e.KeyChar) = True Then
            e.Handled = True
        ElseIf Char.IsPunctuation(e.KeyChar) = True Then
            e.Handled = True
        End If
    End Sub

    Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
        'Close the form
        Me.Close()
    End Sub
End Class

Thank you for your time :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source