error access

Submitted by thientruong on
can you help me solve error when i access system are occur. i give attach file. this is code . Private Sub frmCheckOut_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load Dim cnHotel As OleDbConnection cnHotel = New OleDbConnection Try With cnHotel If .State = ConnectionState.Open Then .Close() .ConnectionString = cnString .Open() End With Catch ex As OleDbException MsgBox(ex.ToString) End Try FillCombobox(cboRateType, "SELECT * FROM Rate_Type", "Rate_Type", "RateType", "RateTypeID") txtRoomNumber.Text = CStr(RoomNumber) dsTransactions.Clear() Dim qryTransactions As String = "SELECT * FROM Transactions WHERE RoomNumber = " & RoomNumber & " AND Status = 'Check In'" daTransactions.SelectCommand = New OleDbCommand(qryTransactions, cnHotel) Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(daTransactions) daTransactions.Fill(dsTransactions, "Transactions") Dim dt As DataTable = dsTransactions.Tables("Transactions") Try txtGuestName.Tag = dt.Rows(0)("FolioNumber") txtGuestName.Text = GetFieldValue("SELECT [Name] FROM qry_CheckIn WHERE FolioNumber = '" & dt.Rows(0)("FolioNumber") & " '", "Name") dtpDateIn.Text = dt.Rows(0)("DateIn") If AutoCheckOut = True Then If dt.Rows(0)("DateOut") >= Today Then dtpDateOut.Value = dt.Rows(0)("DateOut") Else dtpDateOut.Value = Today End If Else dtpDateOut.Value = dt.Rows(0)("DateOut") End If cboRateType.SelectedValue = dt.Rows(0)("RateType") txtDays.Text = dtpDateOut.Value.Subtract(dtpDateIn.Text).Days.ToString txtAdults.Text = dt.Rows(0)("Adults") txtChildrens.Text = dt.Rows(0)("Childrens") txtRate.Text = dt.Rows(0)("Rate") txtOtherCharges.Text = toMoney(dt.Rows(0)("OtherCharges")) txtDiscount.Text = toMoney(dt.Rows(0)("Discount")) txtAmountPaid.Text = toMoney(dt.Rows(0)("AmountPaid")) Catch ex As OleDbException MsgBox(ex.ToString) Finally cnHotel.Close() End Try cboRateType.Enabled = False Call ComputeAddRate() Call ComputeRate() ExecNonQuery("DELETE FolioNumber " & "From [Rate_Per_Period_Temp] " & "WHERE FolioNumber='" & txtGuestName.Tag & "'") ExecNonQuery("INSERT INTO [Rate_Per_Period_Temp] " & "SELECT [Rate_Per_Period].* " & "From [Rate_Per_Period] " & "WHERE FolioNumber='" & txtGuestName.Tag & "'") End Sub and continue Private Sub SaveRecord(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim CustomerID As Short Dim CompanyID As Short If Trim(txtLastName.Text) = "" Or Trim(txtFirstName.Text) = "" Then MsgBox("Vui lòng hoàn thành tên khách.", MsgBoxStyle.Information) Exit Sub End If CustomerID = GetFieldValue("SELECT CustomerID FROM Customers WHERE LastName = '" & txtLastName.Text & "' AND FirstName = '" & txtFirstName.Text & "'", "CustomerID") If CustomerID = 0 Then CustomerID = GetIndex("Customers") ExecNonQuery("INSERT INTO Customers (CustomerID, LastName, FirstName) Values (" & CustomerID & ", '" & txtLastName.Text & "', '" & txtFirstName.Text & "')") End If CompanyID = GetFieldValue("SELECT CompanyID FROM Company WHERE Company = '" & txtCompany.Text & "' ", "CompanyID") If CompanyID = 0 Then If CompanyID = 0 Then CompanyID = GetIndex("Company") ExecNonQuery("INSERT INTO Company (CompanyID, Company) Values (" & CompanyID & ", '" & txtCompany.Text & "')") End If End If Dim dt As DataTable = dsReservation.Tables("Reservation") If State = modGlobal.FormState.adStateAddMode Then ' add a row Dim newRow As DataRow newRow = dt.NewRow() newRow("ReservationNo") = txtReservationNo.Text newRow("Status") = "Reserved" newRow("DateAdded") = Now() 'newRow("ReservedBy") = CurrUser.USER_PK 'newRow("AddedByFK") = CurrUser.USER_PK dt.Rows.Add(newRow) Else dt.Rows(0)("DateModified") = Now 'dt.Rows(0)("LastUserFK") = CurrUser.USER_PK End If With dt .Rows(0)("CustomerID") = CustomerID .Rows(0)("Address") = txtAddress.Text .Rows(0)("CountryID") = cboCountry.SelectedValue .Rows(0)("CompanyID") = CompanyID .Rows(0)("IDTypeID") = cboIDType.SelectedValue .Rows(0)("IDNumber") = txtIDNumber.Text .Rows(0)("RoomNumber") = IIf(cboRoomNumber.Text = "", System.DBNull.Value, cboRoomNumber.SelectedValue) .Rows(0)("DateIn") = dtpDateIn.Value .Rows(0)("DateOut") = dtpDateOut.Value .Rows(0)("RateType") = cboRateType.SelectedValue .Rows(0)("Rate") = txtRate.Text .Rows(0)("OtherCharges") = txtOtherCharges.Text .Rows(0)("Discount") = txtDiscount.Text .Rows(0)("AmountPaid") = txtAmountPaid.Text .Rows(0)("Days") = txtDays.Text .Rows(0)("Adults") = txtAdults.Text .Rows(0)("Childrens") = txtChildrens.Text .Rows(0)("Total") = txtTotal.Text '.Rows(0)("BusinessSourceID") = cboBusinessSource.SelectedValue .Rows(0)("VehicleID") = IIf(cboVehicle.Text = "", System.DBNull.Value, cboVehicle.SelectedValue) .Rows(0)("VehicleModel") = txtVehicleModel.Text .Rows(0)("PlateNo") = txtPlateNo.Text .Rows(0)("Notes") = txtNotes.Text daReservation.Update(dsReservation, "Reservation") End With 'Delete record from Inventory and add a new check in/out date ExecNonQuery("DELETE ID, Status " & "From [Inventory] " & "WHERE ID='" & txtReservationNo.Text & "' AND Status='Reservation'") Dim dtpStartDate As Date dtpStartDate = dtpDateIn.Value Do Until dtpStartDate = Format(dtpDateOut.Value, "Short Date") ExecNonQuery("INSERT INTO [Inventory] ( ID, RoomNumber, [Date], CustomerID, Status ) " & "VALUES ('" & txtReservationNo.Text & "', " & cboRoomNumber.SelectedValue & ", #" & dtpStartDate & "#, " & txtLastName.Tag & ", 'Reservation')") dtpStartDate = System.DateTime.FromOADate(dtpStartDate.ToOADate + 1) Loop blnSaved = True End Sub thanhk everyone