Wrox Programmer Forums
|
BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4
This is the forum to discuss the Wrox book Beginning Dreamweaver MX by Charles E. Brown, Imar Spaanjaars, Todd Marks; ISBN: 9780764544040
Please indicate which version of the book you are using when posting questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4 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
 
Old August 10th, 2007, 06:49 PM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update Record/Check New Username

Hi

I have been using the Beginning Dreamweaver book as a template to develop a website. At this website users can register and edit their personal details. I use DMX's Update Record behaviour to make it possible for the users to update their details. However I would like to prevent them from entering an already existing username, if they decide to edit their username.
The Check New Username behaviour cannot be applies to the Update Record behaviour. I was wondering if there is another way around this?

I'd appreciate any help on this issue.

Thank you
 
Old August 11th, 2007, 04:09 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

If the Server Behavior doesn't support it, you'll need to write some code yourself. Here's what you could do:

1. Right before the Update Behavior executes the UPDATE statement, write some SQL that looks for the current user. E.g.:

sql = "SELECT COUNT(*) FROM YourUsersTable WHERE Name = '" & userName & "'"
Set rsCheck = yourConnection.Execute(sql)
If rsCheck.Fields(0).Value = 0 Then
  userFound = False
Else
  userFound = True
End If
rsCheck.Close()

2. From here, you can use the userFound variable to determine what to do next, like allow the update or redirect to another page.

Alternatively, you can also use the existing Check New Username behavior and adapt it to fit your scenario. This will probably break the behavior in the Behaviors panel, but you can at least reuse the code.

Finally, you can avoid the problem altogether by prohibiting users from changing their user name. Usually, after you sign up, this name can no longer be changed (for example, I can't change my user name here at the Wrox site, other than maybe sending an e-mail to the Administrator).

Regarding your personal message: this forum is not "devoid of activity". It's not very busy because it's about old books, but whenever you post here, you usually get an answer.

Hope this helps.

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old August 12th, 2007, 03:51 PM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar

Thanks very much for your reply, that's very useful. I'm still working at it, ironing a few problems but you've set me on the way, thanks!
 
Old August 13th, 2007, 03:28 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome.

Good luck, and let me know if you have any further questions.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to check the username already exists in table asad_black ASP.NET 2.0 Basics 2 September 15th, 2008 07:19 AM
Getting username for last update on closed xl wb Weebie Beginning VB 6 1 June 13th, 2007 02:14 PM
How do I check a db before inserting a record? Lucy SQL Server ASP 3 April 25th, 2005 10:47 PM
Need HELP!!! Record Input in Field - Check box on karlzoe BOOK: Beginning ASP 3.0 1 April 7th, 2005 09:51 AM
Check for existing record echajmovic Access 1 November 3rd, 2003 08:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.