db record doesn't get written in a Click event

  • Thread starter Thread starter Ken McCrory
  • Start date Start date
K

Ken McCrory

I have a registration page (yeah, it's me again.). The confirmation page
uses the code below to transfer the parameters passed from the first page to
the Insert command parameters then it writes the record to the database.

MoveDataToRecord() 'transfers the Params passed from the first page
to the Insert command parameters

dbconnASM.Open()

dbcmdInsert.ExecuteNonQuery()

dbconnASM.Close()

These four lines work fine if I put them in the Page_Load event. A record
gets written to the database. HOWEVER, if I move those same lines inside a
button click event I get errors that say there isn't any data in the Insert
command parameters.

How long to the Request.Params last? Are they deleted right after the page
is loaded?
 
You are passing the params from the first page to the second page. then on
the second page you are clicking the button?

If this is so you need to save the param that was passed to the second page
for the around trip back to the client and then to the post back to the
server. Save the param to the ViewState. Then get the param from the
ViewState when the button is clicked.
 
Ahh, View State. Hadn't understood it yet because the book I was reading
said it was beyond the scope of the book. <SAMS sucks>. Geez, now that I've
found another book and read some other posts here about View State, this was
something I should have understood earlier this week. Probably accounts for
most of my problems this week. Thanks for pointing this out. Reading
time...need thicker book...

--
Ken "BiggMakk" McCrory

jfleeson said:
You are passing the params from the first page to the second page. then on
the second page you are clicking the button?

If this is so you need to save the param that was passed to the second
page
for the around trip back to the client and then to the post back to the
server. Save the param to the ViewState. Then get the param from the
ViewState when the button is clicked.
 
Back
Top