C
Child
I am trying to insert some data into a table and keep gettting the error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999
11:59:59 PM.
Its me testing the database so the dates should be dates. In the CodeBehind
page of the form that calls this AddEvent function I have tried converting
the txtStartDate.Text to a CDate to pass to this function, but same error.
Is there something obvious i am missing?
function to insert data below, other code upon request:
Public Shared Function AddEvent(ByVal AnEvent As anEvent) As Boolean
Dim sInsert As String = "Insert into tblEvents (EventName, Location,
StartDate, EndDate, Address, City, State, Zip, Phone, ContactName,
ContactPhone, ContactEmail, RoomRate, ReservationCode, Additional, Status,
DateOpened) " _
& "values(" _
& "@EventName, @Location, @StartDate, @EndDate, @Address, @City, @State,
@Zip, @Phone, @ContactName, @ContactPhone, @ContactEmail, @RoomRate,
@ReservationCode, @Additional, @Status, @DateOpened)"
Dim conEvents As New SqlConnection
conEvents.ConnectionString =
ConfigurationSettings.AppSettings("ConnectionString")
Dim cmdEvents As New SqlCommand(sInsert, conEvents)
cmdEvents.Parameters.Add("@EventName", AnEvent.EventName)
cmdEvents.Parameters.Add("@Location", AnEvent.Location)
cmdEvents.Parameters.Add("@DateStart", AnEvent.StartDate)
cmdEvents.Parameters.Add("@DateEnd", AnEvent.EndDate)
cmdEvents.Parameters.Add("@Address", AnEvent.Address)
cmdEvents.Parameters.Add("@City", AnEvent.City)
cmdEvents.Parameters.Add("@State", AnEvent.State)
cmdEvents.Parameters.Add("@Zip", AnEvent.Zip)
cmdEvents.Parameters.Add("@pHONE", AnEvent.Phone)
cmdEvents.Parameters.Add("@ContactName", AnEvent.ContactName)
cmdEvents.Parameters.Add("@ContactPhone", AnEvent.ContactPhone)
cmdEvents.Parameters.Add("@ContactEmail", AnEvent.ContactEmail)
cmdEvents.Parameters.Add("@RoomRate", AnEvent.RoomRate)
cmdEvents.Parameters.Add("@ReservationCode", AnEvent.ReservationCode)
cmdEvents.Parameters.Add("@Additional", AnEvent.Additional)
cmdEvents.Parameters.Add("@Status", AnEvent.STatus)
cmdEvents.Parameters.Add("@DateOpened", AnEvent.DateOpened)
cmdEvents.Parameters.Add("@DateClosed", AnEvent.Dateclosed)
conEvents.Open()
AddEvent = True
Try
cmdEvents.ExecuteNonQuery()
Catch e As SqlException
AddEvent = False
End Try
conEvents.Close()
End Function
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999
11:59:59 PM.
Its me testing the database so the dates should be dates. In the CodeBehind
page of the form that calls this AddEvent function I have tried converting
the txtStartDate.Text to a CDate to pass to this function, but same error.
Is there something obvious i am missing?
function to insert data below, other code upon request:
Public Shared Function AddEvent(ByVal AnEvent As anEvent) As Boolean
Dim sInsert As String = "Insert into tblEvents (EventName, Location,
StartDate, EndDate, Address, City, State, Zip, Phone, ContactName,
ContactPhone, ContactEmail, RoomRate, ReservationCode, Additional, Status,
DateOpened) " _
& "values(" _
& "@EventName, @Location, @StartDate, @EndDate, @Address, @City, @State,
@Zip, @Phone, @ContactName, @ContactPhone, @ContactEmail, @RoomRate,
@ReservationCode, @Additional, @Status, @DateOpened)"
Dim conEvents As New SqlConnection
conEvents.ConnectionString =
ConfigurationSettings.AppSettings("ConnectionString")
Dim cmdEvents As New SqlCommand(sInsert, conEvents)
cmdEvents.Parameters.Add("@EventName", AnEvent.EventName)
cmdEvents.Parameters.Add("@Location", AnEvent.Location)
cmdEvents.Parameters.Add("@DateStart", AnEvent.StartDate)
cmdEvents.Parameters.Add("@DateEnd", AnEvent.EndDate)
cmdEvents.Parameters.Add("@Address", AnEvent.Address)
cmdEvents.Parameters.Add("@City", AnEvent.City)
cmdEvents.Parameters.Add("@State", AnEvent.State)
cmdEvents.Parameters.Add("@Zip", AnEvent.Zip)
cmdEvents.Parameters.Add("@pHONE", AnEvent.Phone)
cmdEvents.Parameters.Add("@ContactName", AnEvent.ContactName)
cmdEvents.Parameters.Add("@ContactPhone", AnEvent.ContactPhone)
cmdEvents.Parameters.Add("@ContactEmail", AnEvent.ContactEmail)
cmdEvents.Parameters.Add("@RoomRate", AnEvent.RoomRate)
cmdEvents.Parameters.Add("@ReservationCode", AnEvent.ReservationCode)
cmdEvents.Parameters.Add("@Additional", AnEvent.Additional)
cmdEvents.Parameters.Add("@Status", AnEvent.STatus)
cmdEvents.Parameters.Add("@DateOpened", AnEvent.DateOpened)
cmdEvents.Parameters.Add("@DateClosed", AnEvent.Dateclosed)
conEvents.Open()
AddEvent = True
Try
cmdEvents.ExecuteNonQuery()
Catch e As SqlException
AddEvent = False
End Try
conEvents.Close()
End Function