Forums

This topic is locked

Check Username?

Posted 09 Feb 2008 10:45:50
1
has voted
09 Feb 2008 10:45:50 Andrew Turner posted:
I am trying to use Check Username to ensure that I do not get two dupliacted records in a database. However what I need to do is not check a name as such but a date. I do not want two entires with the same date in the database, therefore I am trying to use the Check Username feature but pointing it to check on a date field.

It is giving me a Data Type Mismatch error.

Can anyone tell me the best way to go about checking if there is already a record for a given date before inserting another? Or is there a way to edit the code below so it works with a date.

<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "" Then
MM_dupKeyRedirect="intranet_plflash_error.asp"
MM_rsKeyConnection=MM_db_data_STRING
MM_dupKeyUsernameValue = CStr(Request.Form("PL_Flash_Date")
MM_dupKeySQL="SELECT PL_Flash_Date FROM PL_Flash WHERE PL_Flash_Date='" & 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
%>



I am using Dreamweaver MX and writing in ASP.

Many thanks.

Replies

Replied 10 Feb 2008 05:31:43
10 Feb 2008 05:31:43 Javier Castro replied:
I think you would need to check for both username and for date rather than appliyng a comparing a textstring with a date.

Javier
"I'm a slow learner and I forget fast" grandpa
DW | FW | ASP | HTML | CSS

Reply to this topic