db record doesn't get written in a Click event

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?
 
J

jfleeson

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.
 
K

Ken McCrory

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.
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top