 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 3rd, 2005, 04:52 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Update Record Issue
HI All,
I have a table named 'securitytable' with 3 fields(Name, Userid, password).
I have an ASP form where user can change their password. Here is the issue, when they hit submit, everything in the table of that particular record got update even though my SQL statement looks like this(specified ONLY to update the password):
SQLstmt = "UPDATE SecurityTable SET "
SQLstmt = SQLstmt & "password='" & password & "'"
SQLstmt = SQLstmt & " WHERE userid='" & userid & "'"
objConn.Execute(SQLStmt)
In other words, when I go back to view this record, the 'password' field got updated, but the 'Name' and 'userid' fields are blanks, due to the fact that the system thought we meant to update those two fields with blanks.
Is there anyway to prevent from updating everything? Please advise.
Thank you.
Leon
|
|

June 3rd, 2005, 06:44 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Thats wierd, it can't be. Hope to see your asp code, if not too long.
_________________________
- Vijay G
Strive for Perfection
|
|

June 6th, 2005, 10:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Vijay,
Thank you. Below are the codes; there are not much to it b/c my page is not really doing much. All it does is it grabs the new password from the user's input and do an update to the database. Here it is:
[red]<%
'After the user click submit, we have step2
ElseIf Request.form("FormAction") = "Step2" Then
Set objConn = Server.CreateObject("ADODB.Connection")
' Delevopment
objconn.Open "Provider=SQLOLEDB.1; Data Source=(local); Initial Catalog=internship_form; User Id=adminu; Password=adminp"
password=trim(request.form("pswd1"))
userid=trim(request.form("userid"))
SQLstmt = "UPDATE SecurityTable SET "
SQLstmt = SQLstmt & "password='" & password & "'"
SQLstmt = SQLstmt & " WHERE userid='" & userid & "'"
objConn.Execute(SQLStmt)
objConn.Close
set objconn=nothing
End If
%>
|
|

June 6th, 2005, 04:03 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Vijay,
I am not sure if this helps, but I just notice something. You know how i said all the columns are replaced by blanks? Actually, the first 5 columns(of the particular record) did not get replaced, but the columns following the first 5 are replaced with blanks. Does this make any sense? This is too weird. Below is my database structure(the listed columns are in their exact order in the database. And columns with "*" did not get replaced with blanks when I do an update;notice they r the first 5 colunms).
Createdate*
UserID*
Password*
Firstname*
Lastname*
agency
securitylevel
title
phone
email
|
|

June 6th, 2005, 05:22 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Vijay,
I finally figured out what happened. It was the "Form Action" that I made a mistake on. Thank you VERY much for taking your time to help me. And sorry to have wasted your time.
Leon
|
|

June 10th, 2005, 04:26 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Sorry, I haven't got enough time to check my mails for last couple of days. Glad that you solved it.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|
 |