Hi there i have the following code for a hotel management system and whenever i execute the program i get the following error
String was not recognized as a valid Date Time.
Can you help????
Code:Private Sub txtDays_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDays.TextChanged Dim tmpDate As Date tmpDate = dtpDateIn.Value If txtAdults.Tag = "" Then Exit Sub ExecNonQuery("DELETE [DateIn] " & "FROM [Rate_Per_Period] " & "WHERE [DateIn]>#" & dtpDateOut.Value.AddDays(-1) & "#") Dim intAdults As Short If txtAdults.Text = "" Then Exit Sub If CDbl(txtAdults.Text) = hsAdults.Minimum Then intAdults = 0 Else intAdults = CShort(txtAdults.Text) - hsAdults.Minimum End If Dim qry As String = "SELECT * FROM Rate_Per_Period WHERE FolioNumber = '" & txtFolioNumber.Text & "' ORDER BY DateIn" Dim cnHotel As OleDbConnection = New OleDbConnection(cnString) Try Dim da As New OleDbDataAdapter() da.SelectCommand = New OleDbCommand(qry, cnHotel) Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(da) Dim ds As New DataSet() da.Fill(ds, "Rate_Per_Period") Dim dt As DataTable = ds.Tables("Rate_Per_Period") Dim newRow As DataRow Do Until tmpDate > dtpDateOut.Value.AddDays(-1) Dim rows As DataRow() = dt.Select("[DateIn] = #" & tmpDate & "#") If rows.Count = 0 Then newRow = dt.NewRow() newRow("FolioNumber") = txtFolioNumber.Text newRow("DateIn") = tmpDate newRow("RoomNumber") = txtRoomNumber.Text newRow("RateTypeID") = cboRateType.SelectedValue newRow("Rate") = txtRate.Text newRow("Adults") = CDbl(txtAdults.Tag) * intAdults newRow("Childrens") = CDbl(toMoney(txtChildrens.Tag)) * toNumber(txtChildrens.Text) dt.Rows.Add(newRow) End If tmpDate = System.DateTime.FromOADate(tmpDate.ToOADate + 1) Loop da.Update(ds, "Rate_Per_Period") Catch ex As OleDbException MsgBox(ex.ToString) Finally cnHotel.Close() End Try End Sub




Reply With Quote