C
Child
I am feeling frustrated and I am willing to bet its something stupid but I
could really use some help.
I have a class called anEvent. On my web form I have a button which creates
a new anEvent and loads the form data into the new event. It then sends that
event to a class function to try and update the data in the database. When
I hit the button, it appears that nothing happens, no error message, just a
return to the previous state of the controls. I have tried catching errors,
using try - catch to see if something is failing somewhere but have gotten
bascially nowhere. I have tried simplifying the query so much that its
"update tblevents set eventname= @eventname where eventid=@eventid" and
still nothing happens. Please help if you can. Thanks in advance!!
Class:
Public Class anEvent
Public EventName As String
Public Location As String
Public StartDate As DateTime
Public EndDate As DateTime
Public Address As String
Public City As String
Public State As String
Public Zip As String
Public Phone As String
Public ContactPhone As String
Public ContactName As String
Public ContactEmail As String
Public RoomRate As String
Public ReservationCode As String
Public STatus As Integer
Public DateOpened As DateTime
Public Dateclosed As DateTime
Public Additional As String
Public EventID As Integer
End Class
CodeBehind for button:
Private Sub btnUpdateThisEvent_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnUpdateThisEvent.Click
Dim CurrentEvent As New anEvent
Dim URLString As String
CurrentEvent.EventName = txtEventName.Text
CurrentEvent.Location = txtLocation.Text
CurrentEvent.Address = txtAddress.Text
CurrentEvent.City = txtCity.Text
CurrentEvent.State = txtState.Text
CurrentEvent.Zip = txtZip.Text
CurrentEvent.Phone = txtPhone.Text
CurrentEvent.StartDate = txtStartDate.Text
CurrentEvent.EndDate = txtEndDate.Text
CurrentEvent.ContactName = txtContactName.Text
CurrentEvent.ContactPhone = txtContactPhone.Text
CurrentEvent.ContactEmail = txtContactEmail.Text
CurrentEvent.Additional = txtAdditional.Text
CurrentEvent.RoomRate = txtRoomRate.Text
CurrentEvent.ReservationCode = txtReservationCode.Text
CurrentEvent.STatus = ddlStatus.SelectedItem.Value
CurrentEvent.EventID = txtEventID.Text
E_VentManager.EventsDB.UpdateEvent(CurrentEvent)
End Sub
Code for: E_ventManager.EventsDB.UpdateEvent:
Public Shared Function UpdateEvent(ByVal CurrentEvent As anEvent) As Boolean
Dim conEvents As New SqlConnection
conEvents.ConnectionString =
ConfigurationSettings.AppSettings("ConnectionString")
Dim cmdEvents As New SqlCommand
cmdEvents.CommandType = CommandType.StoredProcedure
cmdEvents.CommandText = "spUpdateEvent"
cmdEvents.Connection = conEvents
cmdEvents.Parameters.Add("@EventName", CurrentEvent.EventName)
cmdEvents.Parameters.Add("@Location", CurrentEvent.Location)
cmdEvents.Parameters.Add("@StartDate", CurrentEvent.StartDate)
cmdEvents.Parameters.Add("@EndDate", CurrentEvent.EndDate)
cmdEvents.Parameters.Add("@Address", CurrentEvent.Address)
cmdEvents.Parameters.Add("@City", CurrentEvent.City)
cmdEvents.Parameters.Add("@State", CurrentEvent.State)
cmdEvents.Parameters.Add("@Zip", CurrentEvent.Zip)
cmdEvents.Parameters.Add("@pHONE", CurrentEvent.Phone)
cmdEvents.Parameters.Add("@ContactName", CurrentEvent.ContactName)
cmdEvents.Parameters.Add("@ContactPhone", CurrentEvent.ContactPhone)
cmdEvents.Parameters.Add("@ContactEmail", CurrentEvent.ContactEmail)
cmdEvents.Parameters.Add("@RoomRate", CurrentEvent.RoomRate)
cmdEvents.Parameters.Add("@ReservationCode", CurrentEvent.ReservationCode)
cmdEvents.Parameters.Add("@Additional", CurrentEvent.Additional)
cmdEvents.Parameters.Add("@Status", CurrentEvent.STatus)
cmdEvents.Parameters.Add("@EventID", CurrentEvent.EventID)
conEvents.Open()
cmdEvents.ExecuteNonQuery()
conEvents.Close()
End Function
could really use some help.
I have a class called anEvent. On my web form I have a button which creates
a new anEvent and loads the form data into the new event. It then sends that
event to a class function to try and update the data in the database. When
I hit the button, it appears that nothing happens, no error message, just a
return to the previous state of the controls. I have tried catching errors,
using try - catch to see if something is failing somewhere but have gotten
bascially nowhere. I have tried simplifying the query so much that its
"update tblevents set eventname= @eventname where eventid=@eventid" and
still nothing happens. Please help if you can. Thanks in advance!!
Class:
Public Class anEvent
Public EventName As String
Public Location As String
Public StartDate As DateTime
Public EndDate As DateTime
Public Address As String
Public City As String
Public State As String
Public Zip As String
Public Phone As String
Public ContactPhone As String
Public ContactName As String
Public ContactEmail As String
Public RoomRate As String
Public ReservationCode As String
Public STatus As Integer
Public DateOpened As DateTime
Public Dateclosed As DateTime
Public Additional As String
Public EventID As Integer
End Class
CodeBehind for button:
Private Sub btnUpdateThisEvent_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnUpdateThisEvent.Click
Dim CurrentEvent As New anEvent
Dim URLString As String
CurrentEvent.EventName = txtEventName.Text
CurrentEvent.Location = txtLocation.Text
CurrentEvent.Address = txtAddress.Text
CurrentEvent.City = txtCity.Text
CurrentEvent.State = txtState.Text
CurrentEvent.Zip = txtZip.Text
CurrentEvent.Phone = txtPhone.Text
CurrentEvent.StartDate = txtStartDate.Text
CurrentEvent.EndDate = txtEndDate.Text
CurrentEvent.ContactName = txtContactName.Text
CurrentEvent.ContactPhone = txtContactPhone.Text
CurrentEvent.ContactEmail = txtContactEmail.Text
CurrentEvent.Additional = txtAdditional.Text
CurrentEvent.RoomRate = txtRoomRate.Text
CurrentEvent.ReservationCode = txtReservationCode.Text
CurrentEvent.STatus = ddlStatus.SelectedItem.Value
CurrentEvent.EventID = txtEventID.Text
E_VentManager.EventsDB.UpdateEvent(CurrentEvent)
End Sub
Code for: E_ventManager.EventsDB.UpdateEvent:
Public Shared Function UpdateEvent(ByVal CurrentEvent As anEvent) As Boolean
Dim conEvents As New SqlConnection
conEvents.ConnectionString =
ConfigurationSettings.AppSettings("ConnectionString")
Dim cmdEvents As New SqlCommand
cmdEvents.CommandType = CommandType.StoredProcedure
cmdEvents.CommandText = "spUpdateEvent"
cmdEvents.Connection = conEvents
cmdEvents.Parameters.Add("@EventName", CurrentEvent.EventName)
cmdEvents.Parameters.Add("@Location", CurrentEvent.Location)
cmdEvents.Parameters.Add("@StartDate", CurrentEvent.StartDate)
cmdEvents.Parameters.Add("@EndDate", CurrentEvent.EndDate)
cmdEvents.Parameters.Add("@Address", CurrentEvent.Address)
cmdEvents.Parameters.Add("@City", CurrentEvent.City)
cmdEvents.Parameters.Add("@State", CurrentEvent.State)
cmdEvents.Parameters.Add("@Zip", CurrentEvent.Zip)
cmdEvents.Parameters.Add("@pHONE", CurrentEvent.Phone)
cmdEvents.Parameters.Add("@ContactName", CurrentEvent.ContactName)
cmdEvents.Parameters.Add("@ContactPhone", CurrentEvent.ContactPhone)
cmdEvents.Parameters.Add("@ContactEmail", CurrentEvent.ContactEmail)
cmdEvents.Parameters.Add("@RoomRate", CurrentEvent.RoomRate)
cmdEvents.Parameters.Add("@ReservationCode", CurrentEvent.ReservationCode)
cmdEvents.Parameters.Add("@Additional", CurrentEvent.Additional)
cmdEvents.Parameters.Add("@Status", CurrentEvent.STatus)
cmdEvents.Parameters.Add("@EventID", CurrentEvent.EventID)
conEvents.Open()
cmdEvents.ExecuteNonQuery()
conEvents.Close()
End Function