Growl- frustrating - update function DOESN'T DO ANYTHING

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
 
C

Child

oh yes, and the stored procedure:
CREATE PROCEDURE spUpdateEvent
@EventName varchar(50),
@location varchar(50),
@Phone varchar(50),
@StartDate datetime,
@EndDate datetime,
@Address varchar(255),
@City varchar(50),
@State varchar(50),
@Zip varchar(50),
@ContactName varchar(50),
@ContactPhone varchar(50),
@ContactEmail varchar(50),
@RoomRate varchar(50),
@ReservationCode varchar(50),
@Status integer,
@Additional ntext,
@EventID integer


AS
Begin Transaction
UPDATE tblEvents set EventName = @EventName,
Location = @Location,
Phone = @Phone,
StartDate = @StartDate,
EndDate = @EndDate,
Address = @Address,
City = @City,
State = @State,
Zip = @Zip,
ContactName = @ContactName,
ContactPhone = @ContactPhone,
ContactEmail = @ContactEmail,
RoomRate = @RoomRate,
ReservationCode = @ReservationCode,
Status = @Status,
Additional = @Additional
Where EventID = @EventID


if @@error <> 0 goto Errorhandler
Commit Transaction
return
Errorhandler:
rollback transaction
return
GO
 
P

Patrick Olurotimi Ige

When u say returned to the previous state of the controls
what do u mean?
Is that all ur code?
 
C

Child

Patrick Olurotimi Ige said:
When u say returned to the previous state of the controls
what do u mean?

I change the data in the form, I click the button. The data reverts
OOOOOOOOOOOOOOOOOHHHHHHHHHHHHHH
I am such an idiot. I forgot my not is postback and the page is doing the
page load function every time.

Is that all ur code?


Yes and hugs and kisses to you because your post turned my brain on!
 
H

Hans Kesting

Child wrote:
[snip]
cmdEvents.CommandType = CommandType.StoredProcedure
cmdEvents.CommandText = "spUpdateEvent"
[snip]

Just a sidenote: you should not prefix your SqlServer stored procedures
with "sp" as that will cause SqlServer to look first in "master" and only when
nothing is found there, in your own db. The same probably goes for "xp".

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top