Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My update statement is not updating 1

Status
Not open for further replies.

columbo2

Technical User
Jul 14, 2006
97
GB
Hi All,

I have a datasource with an insert command and parameters as below.
The textboxes referred to are populated and can be edited.
Only trouble is when I run the Update method of the datasource the original textbox value is used in the update (I.e. no change) instead of the new one I type in the text box.

I have a button that simply runs the update method

I get the feeling that I should be doing something else to make the button read the new values of the text box - but I can't find what, can anyone help?

ta
C
...code below


InsertCommand="INSERT INTO jobs (job_title, job_type, job_description, job_location, job_salary) VALUES (@job_title,@job_type,@job_description,@job_location,@job_salary)" SelectCommand="select * from jobs" UpdateCommand="UPDATE jobs SET job_title = @job_title ,job_type = @job_type , job_description = @job_description , job_location = @job_location, job_salary = 'dosh' WHERE job_id = @job_id">
<UpdateParameters>
<asp:ControlParameter ControlID="txbTitle" Name="job_title" PropertyName="text" />
<asp:ControlParameter ControlID="txbType" Name="job_type" PropertyName="text" />
<asp:ControlParameter ControlID="txbDescription" Name="job_description" PropertyName="text" />
<asp:ControlParameter ControlID="txbLocation" Name="job_location" PropertyName="text" />
<asp:ControlParameter ControlID="txbSalary" Name="job_salary" PropertyName="text" />
<asp:ControlParameter ControlID="litJob_id" Name="job_id" PropertyName="text" />
</UpdateParameters>
 
Hi, Thanks for your answer.
The table on the page is populated by a datareader that reads the record from the database. So everytime the page runs it gets the latest from the database.
This populates the textboxes, I then use a datasource to handle the add and update commands.

The add function works fine, but the update function doesn't for some reason.
It seems like when I hit the update button the app isn't looking for the latest contents of the text boxes.

I was worried that when I hit the update button it reloads with the old data before it does the update. But I don't think that is happening because when you click the button it runs the update before it does anything else (or it seems to from the tracking I've been doing).
But if calling that button click event causes a page refresh (i.e. the on page load routine to load) then that could be happening.
Is that what your saying?
(sorry if I'm not making sense)
 
Thanks ca8msm,

You were right, much appreciated.

Cheers for all your help
C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top