Forums

This topic is locked

Logic is gone

Posted 14 Jun 2003 01:19:22
1
has voted
14 Jun 2003 01:19:22 Ken Dobson posted:
I think I've fried my logic, if it was there to begin with. I'm crosseyed now. Hopefully someone can point out my error. I'm making a user registration form and I do not want to save duplicate usernames. My registration form sends the user to a page (username_check.asp) that tries to verify if the username already exists in the database. I open up the recordset on username_check.asp with just the username and I'm also passing the username from the previous form to this page. On this page, I put an Insert Behavior. I've gone on to use Dreamweavers code to check to see if the recordset is blank. If it is, then that means the username does not exist and it's safe to insert the new user. If it's not, I want to redirect back to the registration page with a message that the username chosen already exists. *whew* Ok. Below is the code that I thought would work, but alas, only made me more stupider. (yes, that was a joke) The red lines below are my code. The first red line is the line that is incorrect, but I just can't seem to think of a way to make this work.

If (Not MM_abortEdit) Then
'Find out if a username already exists, if not, then save record
<font color=red>If RS1.EOF And RS1.BOF Then</font id=red>
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery

MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
<font color=red>Response.Redirect("registration_complete.asp"
Else
Response.Redirect("duplicate_user_name.asp"
End If ' end RS1.EOF And RS1.BOF </font id=red>
End If

The problem is that it always drops into the first IF statement, regardless if a username with the same name already exists. Then I receive a duplication error.

Thanks for any help. Have a great weekend!!

Ken

Replies

Replied 14 Jun 2003 19:05:47
14 Jun 2003 19:05:47 Marcellino Bommezijn replied:
Try:

If Not RS1.EOF Or Not RS1.BOF Then
Replied 16 Jun 2003 17:58:58
16 Jun 2003 17:58:58 Ken Dobson replied:
Man. I tried so many different things, I could have sworn I did that one. Guess not, because it worked. Just goes to show you it's the simple things that get you everytime.

Thanks!!!

Ken
Replied 17 Jun 2003 00:43:51
17 Jun 2003 00:43:51 Ken Dobson replied:
I spoke too soon. It was always jumping in the ELSE and unfortunately, that's all I tested this morning. It wasn't until I tested the "new username" or first IF statement, that I discovered EVERY thing was jumping into the ELSE statement. I can get it to work one way, but not both. Most times, I get the following error, which is what I'm trying to avoid:

---------------------ERROR---------------------------------------
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

Microsoft ODBC Microsoft Access Driver: The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
--------------------------------------------------------------------

Any other thoughts?


Edited by - warmonger on 17 Jun 2003 01:09:56
Replied 17 Jun 2003 23:36:33
17 Jun 2003 23:36:33 Ken Dobson replied:
I'm such an idiot. It wasn't the logic afterall. I was basing the logic on a request.form var and my page was setup for a querystring. Change it to be a request.form and voila, it works. Three days of suffering all because of something this idiotic.

FYI: The original post above works great if anyone else tries to do this in the future.

Reply to this topic