473,382 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Updating record in DB HELP

Hi,

I am updating a website for my final year project at university, I was wondering if anyone can help.

I am trying to write a script that allows the user to update their email address.
which is also their login. I have written the following script, however, its just adds the new email address as oppose to replacing it. can anyone tell me where i'm going wrong?

<%

Dim strNEW 'New email string

Dim strCONFIRM 'Confirmed email string

Dim strOLD 'old email address string


strOLD = Trim(Request.Form("User_Login") )

strNEW = Trim(Request.Form("New_email") )

strCONFIRM = Trim(Request.Form("Confirm_email") )

%>



<!--#include file="dbOpen.asp"-->

<%

If (strNew <> strCONFIRM) Then

Response.Redirect("my_email_retry.asp")

Else

'qry="select user_id from tblRegUser WHERE user_Email ='" + strNEW + "'"
'set rsChk = Conn.execute(qry)
'IF rsChk.EOF THEN
Conn.BeginTrans
qry="Insert Into tblRegUser(user_Email) VALUES('" & strNEW & "')"
Conn.execute(qry)
Conn.CommitTrans
'END IF

Response.Redirect("disp_login.asp")


%>

<% End IF %>
Mar 20 '07 #1
1 1148
Hi

You need to use the SQL Update command rather than the insert command. You need to know which record to update and you would normally use an ID field (usually a unique number) to update the correct record.

However in your case you can probably get away with using their old email address as the field to update, so your query would be, e.g.

Expand|Select|Wrap|Line Numbers
  1. qry="Update tblRegUser Set user_Email =  '" & strNEW & "' Where user_Email = '" & strOLD & '" 
In order for this to work, the old email address that the user types in would have to be the same case - if they type it in once in lower case but then later use upper case, this won't work. You could also get around that by converting their input and the database field to lowercase so that the check would work every time.

Hope that helps.

Dale
Mar 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Chris Jackson | last post by:
I'm a novice Access user and am not sure how to solve the following problem. Any help with the following would be greatly appreciated! I have two tables with identical structures, the first holds...
3
by: MLH | last post by:
I have a form, bound to a query. Its RecordSource property is a query named frmEnterLienAmounts. The form has a few bound controls and some unbound controls. The unbound controls are calculated...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
5
by: Hexman | last post by:
I've come up with an error which the solution eludes me. I get the error: >An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in HRTest.exe > >Additional...
4
by: aaronyoung | last post by:
I have created custom navigation buttons and Record Number indicators on several forms that are used to review and update records based on a query. My On Current event to update the "Record X of...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.