473,804 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Beginner's problem: A problem with pre-filled forms

Hello! I'm building an application where the user can update his own
personal information in a database using a form. The program fetches the
user's information from the database, fills the form with this information,
then the user makes the changes that he wants, clicks the "Update" button
and the updated information is sent back to the database. But I have a
problem. My program is supposed to work like this:

txtNamefield.te xt = "John Smith"
- a text field is filled with old information fetched from the database
- the user changes this name, and clicks "Update"

Dim name as String
name = txtNamefield.te xt
Dim Sqlsentence as string
Sqlsentence = "UPDATE tableUser SET NAME = '" & name & "' WHERE USERID=XXX;"
- the value of the text field is read to the variable "name" and the
Sqlsentence is executed.

But the value sent to the database is still the same old value, "John
Smith", even though the user changed it and it vas read to the variable
"name".

If I don't fill the textfields in advance the program reads the values
correctly. I would be very happy if someone could let me know what I'm doing
wrong. Thank you very much in advance!

Toni S.
Jul 29 '06 #1
3 1170
I think you are setting the text field every time the page loads
INCLUDING when you post back the changed value.

What you need to do is only set the text field when the page first
loads but not when you click update and it posts back:

If Not Page.IsPostBack Then
'set values from database
End If

PS: Remember that the method you are using is dangerous security-wise
as people could pass sql code through to your page. Using the
validation controls will block this for you.

Toni wrote:
Hello! I'm building an application where the user can update his own
personal information in a database using a form. The program fetches the
user's information from the database, fills the form with this information,
then the user makes the changes that he wants, clicks the "Update" button
and the updated information is sent back to the database. But I have a
problem. My program is supposed to work like this:

txtNamefield.te xt = "John Smith"
- a text field is filled with old information fetched from the database
- the user changes this name, and clicks "Update"

Dim name as String
name = txtNamefield.te xt
Dim Sqlsentence as string
Sqlsentence = "UPDATE tableUser SET NAME = '" & name & "' WHERE USERID=XXX;"
- the value of the text field is read to the variable "name" and the
Sqlsentence is executed.

But the value sent to the database is still the same old value, "John
Smith", even though the user changed it and it vas read to the variable
"name".

If I don't fill the textfields in advance the program reads the values
correctly. I would be very happy if someone could let me know what I'm doing
wrong. Thank you very much in advance!

Toni S.
Jul 29 '06 #2
"Toni" <no****@hotmail 555.comwrote in message
news:uH******** ******@TK2MSFTN GP02.phx.gbl...

Could it simply be that you're fetching the initial values in the Page_Load
event regardless of whether the page is being opened as a result of a
postback or not...? E.g.

If Not Page.IsPostback
' fetch the initial values - don't do this when updating!
End If
Jul 29 '06 #3
Page_Load() fires prior to button events.

Make sure you are setting the value only when IsPostBack() is false. If not,
you are setting the value again prior to saving, thus saving the original
value.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** ****
Think Outside the Box!
*************** *************** *************** ****
"Toni" <no****@hotmail 555.comwrote in message
news:uH******** ******@TK2MSFTN GP02.phx.gbl...
Hello! I'm building an application where the user can update his own
personal information in a database using a form. The program fetches the
user's information from the database, fills the form with this
information, then the user makes the changes that he wants, clicks the
"Update" button and the updated information is sent back to the database.
But I have a problem. My program is supposed to work like this:

txtNamefield.te xt = "John Smith"
- a text field is filled with old information fetched from the database
- the user changes this name, and clicks "Update"

Dim name as String
name = txtNamefield.te xt
Dim Sqlsentence as string
Sqlsentence = "UPDATE tableUser SET NAME = '" & name & "' WHERE
USERID=XXX;"
- the value of the text field is read to the variable "name" and the
Sqlsentence is executed.

But the value sent to the database is still the same old value, "John
Smith", even though the user changed it and it vas read to the variable
"name".

If I don't fill the textfields in advance the program reads the values
correctly. I would be very happy if someone could let me know what I'm
doing wrong. Thank you very much in advance!

Toni S.

Jul 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1439
by: peterlai | last post by:
<html> <head> </head> <body><pre> <?php $connection = odbc_connect("test","root","passwd");
3
1935
by: ·sÂA¤H | last post by:
Hi All, I am a beginner of XML, my final year project is using a XML and JAVA to develop a Workflow Management System. It make me very confuse. I don't even know how to use the XML to exchange data throught the Internet. Could anyone can give me a little advise and What should I do first? Develop a DTD first?
1
1713
by: Renee | last post by:
I am doing a simple client-side example using DOM in JScript. When the user enter info and click on the submit button, it will then print the value at the bottom of the page. However, I don't know what's wrong that the entered values are not printed out. Can anyone please help me??? Any reply is appreciated. My code is as follow, you can copy and run it yourself. File name: bookClient.htm <html>
44
4292
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there must be many know the answer here. thanks
39
2427
by: TonyJeffs | last post by:
Great book - I like the way that unlike other books, AC++ explains as much as possible about every piece of code discussed, so I'm not left thinking, "well...OK... I get line 12, but I wonder what the rest of it means...". Still, I have some questions, that are frustrating me:- Grateful for any comments. 1. What is the difference between #include <iostream> // (or any include file) which is used in this
19
2028
by: What-a-Tool | last post by:
I have a school project (ASP) in which I have to call three different ASP pages from three different and identical (except for the form "action", obviously) HTM pages. This I have no problem with. However, as a personal learning project and challenge, I decided to see if I could code my initial HTM page to call any of the three ASP pages, depending on the condition of an option group. (3 buttons - id="function", id="sub", id="class") I...
2
1626
by: Kris Krieger | last post by:
Hello, Group, I hope it's OK for me to ask this question here, since I'm a "dabbler", not a "programmer". What I'd like to do, if it's possible, is find a reference or example/template that will show me how to create a "quote gallery" that uses a mouseover/mouseout to show/hide text in a layer - the idea is that, when the visitor mouses over a quote title, the appropriate text is called from a separate file and shows in a reserved and...
24
8545
by: silversurfer2025 | last post by:
Hello. I do not know whether this really is the right group, but I could not find any group dealing only with GUIs for C++ so here I am. I am currently deciding which GUI to use in my program. It should be able to show - graphs - contents of textfiles - images (ppm or whatever) - radio buttons, etc (user input elements)
1
7710
by: vocalise | last post by:
The title probably isn't very clear, but I haven't been able to find this problem (or I must be having problems figuring out which search strings to use) so I apologize if this has been addressed before, and I apologize if this is the wrong forum since I'm trying to use the XMLHTTPRequest with Javascript and PHP and I couldn't figure out which category my problem belonged to. I am completely new to AJAX and rusty with Javascript. I created a...
15
4203
by: JohnDriver | last post by:
Hello I am learning Ajax and I am following the tutorials found but for some reason, my code is not working. I think I am missing something in the code that I am posting below. Please have a look and let me know. <html> <head> <script> function submitForm() { var test;
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.