stored procedure

  • Thread starter Thread starter nicholas
  • Start date Start date
N

nicholas

Anyone can help me with creating a stored procedure that is only executed
when the form is submitted?

So, I have a form that should inserts values in a table. This goes with a
stored procedure. But ofcourse the value should first be filled in the
webform, and for this I have to prevent the form from executing unless the
user submits the form (and passes the form validation).

THX


Here's my SP:


CREATE PROCEDURE spaddpicture

(@picturename nvarchar, @picturedescription ntext, @picturepricecat int,
@picturepath nvarchar, @picturethumbpath nvarchar, @picturepeople bit,
@picturehigh int, @picturewidth int, @pictureweight int, @categoryID int,
@pictureID int OUTPUT)

AS

INSERT INTO tbl_pictures ([picturename], [picturedescription],
[picturepricecat], [picturepath], [picturethumbpath], [picturepeople],
[picturehigh], [picturewidth], [pictureweight])

VALUES (@picturename, @picturedescription, @picturepricecat, @picturepath,
@picturethumbpath, @picturepeople, @picturehigh, @picturewidth,
@pictureweight)

SET @pictureID = @@IDENTITY

INSERT INTO tbl_picscats (pictureID, categoryID)

VALUES (@pictureID, @categoryID)


Return
GO
 
Well, you just don't call the stored procedure until everything is
validated:

private void Page_Load(...) {
if (Page.IsPostBack) {
Page.Validate;
if (Page.IsValid) {
// call stored procedure
}
}
}
 
Back
Top