Forums
This topic is locked
Using Check New User (Duplicate Records)
Posted 08 Oct 2002 14:54:43
1
has voted
08 Oct 2002 14:54:43 Phil Robles posted:
I am having problems trying to use a modified version of 'Check New User Name' to see if a field value currently exists based upon session variable. In other words, I want to be ensure that a user doesn't try to add a new record that contains duplicate values within the field called 'TrackID.' I believe my problem lies within the SQL statemetn because I get an error that reads: Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression 'TrackID= 81 AND UserName= ''.
I appreciate any help because I'm at a lost on how to fix this!
<%
' *** Redirect If Session Variable Does Not Exist
If Session("MM_UserName"

Response.Redirect("error.asp"

End If
%>
<!--#include file="../Connections/solicitations.asp" -->
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL"

If (Request.QueryString <> ""

MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Redirect if TrackID exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> ""

MM_dupKeyRedirect="recordexists.asp"
MM_rsKeyConnection=MM_viainfo_STRING
MM_dupKeyUsernameValue = CStr(Request.Form("TrackID"

'Stock code adds the apostrophe and you do not want those in the sql statement so remove them
'Ensure you add the UserName Variable of MM_UserName within the SQL statement
MM_dupKeySQL="SELECT TrackID FROM tbltrackRFPs WHERE TrackID= " & MM_dupKeyUsernameValue & " AND UserName = '" & MM_UserName & "'"
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,"?"

MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "TrackID=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
Frenzy