Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Check Column Value

New Here ,
Jun 21, 2007 Jun 21, 2007
I have a course registration application in ASP (VB Script). When a user goes to register for a course, I need an extension that will allow them to register for the course only once. The field i'm currently using is a number datatype. I tried to use the Check New Username Extension, but when I do, it throws a datatype mismatch error at me. I am assuming this is being caused by the extension only allowing the username column to be in a text datatype. If the Check New Username extension would allow numer datatypes for the Username columns, I believe this would work. Are there any workarounds or extensions out there for this?

Thank you in advance...

Ken S.
TOPICS
Server side applications
551
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 21, 2007 Jun 21, 2007
You can modify the code for the checkusername behavior, i have made it check for update behavior, and if you want to validate a number look in the code below for the section with three numbers 200, 1 , 50 (text) the last one might be different for you as its the maximum length of the field, change those numbers to (5, 1, -1) (numeric) check the numbers on the last line of the code below my numbers represent text with maxlength of 50 last number, That should work.

MM_dupKeyRedirect = "YOURREDIRECT.asp"
MM_dupKeyUsernameValue = CStr(Request.Form("UserName"))
Set MM_rsKey_cmd = Server.CreateObject ("ADODB.Command")
MM_rsKey_cmd.ActiveConnection = MM_cvrranchdb_STRING
MM_rsKey_cmd.CommandText = "SELECT UserName FROM UsersLog WHERE UserName = ?"
MM_rsKey_cmd.Prepared = true
MM_rsKey_cmd.Parameters.Append MM_rsKey_cmd.CreateParameter("param1", 200, 1, 50, MM_dupKeyUsernameValue) '
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 21, 2007 Jun 21, 2007
I don't see the 200,1,50. Here is the code I see:

<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
MM_dupKeyRedirect="AlreadySignedUp.asp"
MM_rsKeyConnection=MM_register_STRING
MM_dupKeyUsernameValue = CStr(Request.Form("schedID"))
MM_dupKeySQL="SELECT Course1 FROM Test_Registrations WHERE Course1='" & Replace(MM_dupKeyUsernameValue,"'","''") & "'"
MM_adodbRecordset="ADODB.Recordset"
set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
MM_rsKey.ActiveConnection=MM_rsKeyConnection
MM_rsKey.Source=MM_dupKeySQL
MM_rsKey.CursorType=0
MM_rsKey.CursorLocation=2
MM_rsKey.LockType=3
MM_rsKey.Open
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>

Any ideas?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 21, 2007 Jun 21, 2007
You could try to put this code in your page, I am using DW8 but it should work as its ASP code:

<%
' *** Redirect if username exists
MM_flag = "MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
Dim MM_rsKey
Dim MM_rsKey_cmd

MM_dupKeyRedirect = "AlreadySignedUp.asp"
MM_dupKeyUsernameValue = CStr(Request.Form("schedID")
Set MM_rsKey_cmd = Server.CreateObject ("ADODB.Command")
MM_rsKey_cmd.ActiveConnection = MM_register_STRING
MM_rsKey_cmd.CommandText = "SELECT Course1 FROM Test_Registrations WHERE Course1=?"
MM_rsKey_cmd.Prepared = true
MM_rsKey_cmd.Parameters.Append MM_rsKey_cmd.CreateParameter("param1", 5, 1, -1, MM_dupKeyUsernameValue) ' adVarChar
Set MM_rsKey = MM_rsKey_cmd.Execute
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1, MM_dupKeyRedirect, "?") >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2007 Jun 22, 2007
LATEST
The script doesn't work. When I try to register for a course, it redirects me to the "Already registered" page even though I haven't registered for the course. In other words, there is no value to compare it with, so I don't know what it's checking.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 22, 2007 Jun 22, 2007
are you using "text" as a datatype?

then just try "varchar(25)" - maybe this helps (25 for the lenght)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2007 Jun 22, 2007
Using Access and it will work if I change the field datatype to text, but I would prefer to keep it a number field.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines