Updating Database

D

Dot Net Daddy

Hello,

I have some textareas assigned some values which is taken from the
database on page_load. Also there is an update button.

But when I change the text and click the update button it does not
work. Actually it works, but the text I type in the textarea is not
recognized. It recognizes the assigned value on page_load, and updates
the same thing over itself.


Here is my code:


sqlDS.UpdateCommand = "UPDATE Blogs SET diaryHeader='" &
TextBox1.Text.Replace("'", "''") & "', diaryInfo='" &
TextBox2.Text.Replace("'", "''") & "', lastUpdate='" & Today.Now & "'
WHERE userName='" & User.Identity.Name & "' AND diaryDate='" &
Label4.Text & "'"
sqlDS.Update()
Label6.Text = "Great"


Thanks in advance.
 
C

Cowboy \(Gregory A. Beamer\)

Does the Page_Load use If Not Page.IsPostBack Then?

If not, you are resetting the form in Page_Load prior to your update button
event.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
 
D

Dot Net Daddy

No I didn't use If Not Page.IsPostBack Then ...

but I understand what you mean, however I couldnt get it into code. I
am updating the database on Button.Click event.

Maybe copying the same code in the Button_Click into Page_Load under
If Page.IsPostback would work. But the problem is there is no way to
access the page from the address bar. I mean the page is a cross page
post back from another page. So it might cause problems.

Actually would work in practice, but on first page load it updates
itself, am I right?
 
D

Dot Net Daddy

No, you were right. It works fine now in If Not Page.IsPostBack clause

Thanks for your help...
 

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

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top