Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Adding Duplicates help


Message #1 by "Robert Boczkay" <rboczkay@e...> on Tue, 20 Aug 2002 14:51:02
I have a webpage that allows a user to add to the database.  If the 
database already has a record with that cell phone number in it, I want it 
to redirect to another page.  I have been trying multiple ways of doing 
this for 2 weeks now and cannot figure it out.  I would greatly appreciate 
it if someone could help me . Thanks!  Here is my code:

<%
'If the session variable is False or does not exsist then redirect the 
user to the unauthorised user page
If Session("TADA") = False or IsNull(Session("TADA")) = True then
 
 'Redirect to unathorised user page
 Response.Redirect"unauthorised_user_page.htm"
End If
%>

<%
'Dimension variables
Dim adoCon
Dim rsAddComments
Dim strSQL
Dim Errortime
Dim newSQL
Dim cellular
Dim cellvar

Errortime = False
celluar = Request.Form("requiredCELLS")

Set adoCon = Server.CreateObject("ADODB.Connection")

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & 
Server.MapPath("\FORMYEYESONLY\db\database.mdb")

Set rsAddComments = Server.CreateObject("ADODB.Recordset")

'strSQL = "SELECT Master_List.* FROM Master_List;"
strSQL = "SELECT Master_List.* FROM Master_List WHERE 
Master_List.CELLPHONE ='" & cellular & "'"

rsAddComments.CursorType = 2

rsAddComments.LockType = 3

rsAddComments.Open strSQL, adoCon

If strSQL = TRUE Then

     Response.Redirect "http://www.yahoo.com"

Else

rsAddComments.AddNew

rsAddComments.Fields("LASTNAME") = Request.Form("LAST")
rsAddComments.Fields("FIRSTNAME") = Request.Form("FIRST")
rsAddComments.Fields("MID") = Request.Form("MIDDLE")
rsAddComments.Fields("NETID") = Request.Form("NET")
rsAddComments.Fields("EMAIL") = Request.Form("EMAILS")
rsAddComments.Fields("SUBUNITDEPT") = Request.Form("DEPTS")
rsAddComments.Fields("SUBUNITDES") = Request.Form("DESCS")
rsAddComments.Fields("BUILDINGNAME") = Request.Form("BNAME")
rsAddComments.Fields("PHONENUMBER") = Request.Form("PHONE")
rsAddComments.Fields("CUBENUMBER") = Request.Form("CUBE")
rsAddComments.Fields("MAILCODE") = Request.Form("MAILC")
rsAddComments.Fields("FLOOR") = Request.Form("FLOORS")
rsAddComments.Fields("CELLPHONE") = Request.Form("requiredCELLS")
rsAddComments.Fields("FAXNUMBER") = Request.Form("FAX")
rsAddComments.Fields("PAGERNUMBER") = Request.Form("PAGER")
rsAddComments.Fields("TITLE") = Request.Form("TITL")
rsAddComments.Fields("CONTRACTHO") = Request.Form("EMPLOYER")
rsAddComments.Fields("CLASSIFICATION") = Request.Form("CLIF")
rsAddComments.Fields("WHOLENAME") = Request.Form("WHOLE")
rsAddComments.Fields("STREETADDRESS") = Request.Form("ADDY")
rsAddComments.Fields("CITY") = Request.Form("CITIES")
rsAddComments.Fields("STATE") = Request.Form("STATES")
rsAddComments.Fields("ZIP") = Request.Form("ZIPS")
rsAddComments.Fields("OFFICEPHONEEXT") = Request.Form("OFFPH")
rsAddComments.Fields("SUBACCOUNT") = Request.Form("SUBACC")
rsAddComments.Fields("HANDSETMAKE") = Request.Form("HMAKE")
rsAddComments.Fields("HANDSETMODEL") = Request.Form("HMODEL")
rsAddComments.Fields("ADMINRIGHTS") = Request.Form("ARIGHTS")
rsAddComments.Fields("MANAGEDDEPT") = Request.Form("MGED")
rsAddComments.Fields("IME") = Request.Form("IMEIESN")
rsAddComments.Fields("FLEET") = Request.Form("FLT")
rsAddComments.Fields("MEMBERNUMBER") = Request.Form("MEMNUM")
rsAddComments.Fields("RATEPLAN") = Request.Form("RPLAN")
rsAddComments.Fields("USEDAS") = Request.Form("USED")
rsAddComments.Fields("VENDOR") = Request.Form("VNDR")
rsAddComments.Fields("SERVICE") = Request.Form("SRVC")
rsAddComments.Fields("NOTES") = Request.Form("note")

rsAddComments.Update

rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing

Response.Redirect "DatabaseSelect.asp"

End If
%>
Message #2 by "Darrell" <darrell@b...> on Tue, 20 Aug 2002 19:12:06 +0100
Hi Robert

You are going about this the wrong way.

Do a simple end of file check as follows:

if rsAddComments.EOF then    'If the cellular phone number is not found this
will be true
	response.redirect "wherever.asp"
else
	rsAddComments.AddNew


Cheers
Darrell

-----Original Message-----
From: Robert Boczkay [mailto:rboczkay@e...]
Sent: 20 August 2002 14:51
To: Access ASP
Subject: [access_asp] Adding Duplicates help


I have a webpage that allows a user to add to the database.  If the
database already has a record with that cell phone number in it, I want it
to redirect to another page.  I have been trying multiple ways of doing
this for 2 weeks now and cannot figure it out.  I would greatly appreciate
it if someone could help me . Thanks!  Here is my code:

<%
'If the session variable is False or does not exsist then redirect the
user to the unauthorised user page
If Session("TADA") = False or IsNull(Session("TADA")) = True then

 'Redirect to unathorised user page
 Response.Redirect"unauthorised_user_page.htm"
End If
%>

<%
'Dimension variables
Dim adoCon
Dim rsAddComments
Dim strSQL
Dim Errortime
Dim newSQL
Dim cellular
Dim cellvar

Errortime = False
celluar = Request.Form("requiredCELLS")

Set adoCon = Server.CreateObject("ADODB.Connection")

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
Server.MapPath("\FORMYEYESONLY\db\database.mdb")

Set rsAddComments = Server.CreateObject("ADODB.Recordset")

'strSQL = "SELECT Master_List.* FROM Master_List;"
strSQL = "SELECT Master_List.* FROM Master_List WHERE
Master_List.CELLPHONE ='" & cellular & "'"

rsAddComments.CursorType = 2

rsAddComments.LockType = 3

rsAddComments.Open strSQL, adoCon

If strSQL = TRUE Then

     Response.Redirect "http://www.yahoo.com"

Else

rsAddComments.AddNew

rsAddComments.Fields("LASTNAME") = Request.Form("LAST")
rsAddComments.Fields("FIRSTNAME") = Request.Form("FIRST")
rsAddComments.Fields("MID") = Request.Form("MIDDLE")
rsAddComments.Fields("NETID") = Request.Form("NET")
rsAddComments.Fields("EMAIL") = Request.Form("EMAILS")
rsAddComments.Fields("SUBUNITDEPT") = Request.Form("DEPTS")
rsAddComments.Fields("SUBUNITDES") = Request.Form("DESCS")
rsAddComments.Fields("BUILDINGNAME") = Request.Form("BNAME")
rsAddComments.Fields("PHONENUMBER") = Request.Form("PHONE")
rsAddComments.Fields("CUBENUMBER") = Request.Form("CUBE")
rsAddComments.Fields("MAILCODE") = Request.Form("MAILC")
rsAddComments.Fields("FLOOR") = Request.Form("FLOORS")
rsAddComments.Fields("CELLPHONE") = Request.Form("requiredCELLS")
rsAddComments.Fields("FAXNUMBER") = Request.Form("FAX")
rsAddComments.Fields("PAGERNUMBER") = Request.Form("PAGER")
rsAddComments.Fields("TITLE") = Request.Form("TITL")
rsAddComments.Fields("CONTRACTHO") = Request.Form("EMPLOYER")
rsAddComments.Fields("CLASSIFICATION") = Request.Form("CLIF")
rsAddComments.Fields("WHOLENAME") = Request.Form("WHOLE")
rsAddComments.Fields("STREETADDRESS") = Request.Form("ADDY")
rsAddComments.Fields("CITY") = Request.Form("CITIES")
rsAddComments.Fields("STATE") = Request.Form("STATES")
rsAddComments.Fields("ZIP") = Request.Form("ZIPS")
rsAddComments.Fields("OFFICEPHONEEXT") = Request.Form("OFFPH")
rsAddComments.Fields("SUBACCOUNT") = Request.Form("SUBACC")
rsAddComments.Fields("HANDSETMAKE") = Request.Form("HMAKE")
rsAddComments.Fields("HANDSETMODEL") = Request.Form("HMODEL")
rsAddComments.Fields("ADMINRIGHTS") = Request.Form("ARIGHTS")
rsAddComments.Fields("MANAGEDDEPT") = Request.Form("MGED")
rsAddComments.Fields("IME") = Request.Form("IMEIESN")
rsAddComments.Fields("FLEET") = Request.Form("FLT")
rsAddComments.Fields("MEMBERNUMBER") = Request.Form("MEMNUM")
rsAddComments.Fields("RATEPLAN") = Request.Form("RPLAN")
rsAddComments.Fields("USEDAS") = Request.Form("USED")
rsAddComments.Fields("VENDOR") = Request.Form("VNDR")
rsAddComments.Fields("SERVICE") = Request.Form("SRVC")
rsAddComments.Fields("NOTES") = Request.Form("note")

rsAddComments.Update

rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing

Response.Redirect "DatabaseSelect.asp"

End If
%>

Message #3 by "Robert Boczkay" <rboczkay@e...> on Tue, 20 Aug 2002 19:46:38
I've tried that too...it doesn't work!  I have no clue why!

Rob
Message #4 by "Ken Schaefer" <ken@a...> on Wed, 21 Aug 2002 10:48:29 +1000
This line is incorrect:

: If strSQL = TRUE Then

strSQL will never equal True. True is a boolean. strSQL is a string that
contains:
SELECT Master_List.* FROM Master_List WHERE aster_List.CELLPHONE
='0000000000'

(where 000000000 is what is supplied by the user).

Instead, you want to do something like:

<%
If objRS.EOF then
    ' User *does not exist*
Else
    ' User does exist
End If
%>

Note that this is subtley different to what Darrell suggested (ie the
conditional test is the other way around!)

Cheers
Ken


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: "Robert Boczkay" <rboczkay@e...>
To: "Access ASP" <access_asp@p...>
Sent: Tuesday, August 20, 2002 2:51 PM
Subject: [access_asp] Adding Duplicates help


: I have a webpage that allows a user to add to the database.  If the
: database already has a record with that cell phone number in it, I want it
: to redirect to another page.  I have been trying multiple ways of doing
: this for 2 weeks now and cannot figure it out.  I would greatly appreciate
: it if someone could help me . Thanks!  Here is my code:
:
: <%
: 'If the session variable is False or does not exsist then redirect the
: user to the unauthorised user page
: If Session("TADA") = False or IsNull(Session("TADA")) = True then
:
:  'Redirect to unathorised user page
:  Response.Redirect"unauthorised_user_page.htm"
: End If
: %>
:
: <%
: 'Dimension variables
: Dim adoCon
: Dim rsAddComments
: Dim strSQL
: Dim Errortime
: Dim newSQL
: Dim cellular
: Dim cellvar
:
: Errortime = False
: celluar = Request.Form("requiredCELLS")
:
: Set adoCon = Server.CreateObject("ADODB.Connection")
:
: adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
: Server.MapPath("\FORMYEYESONLY\db\database.mdb")
:
: Set rsAddComments = Server.CreateObject("ADODB.Recordset")
:
: 'strSQL = "SELECT Master_List.* FROM Master_List;"
: strSQL = "SELECT Master_List.* FROM Master_List WHERE
: Master_List.CELLPHONE ='" & cellular & "'"
:
: rsAddComments.CursorType = 2
:
: rsAddComments.LockType = 3
:
: rsAddComments.Open strSQL, adoCon
:
: If strSQL = TRUE Then
:
:      Response.Redirect "http://www.yahoo.com"
:
: Else
:
: rsAddComments.AddNew
:
: rsAddComments.Fields("LASTNAME") = Request.Form("LAST")
: rsAddComments.Fields("FIRSTNAME") = Request.Form("FIRST")
: rsAddComments.Fields("MID") = Request.Form("MIDDLE")
: rsAddComments.Fields("NETID") = Request.Form("NET")
: rsAddComments.Fields("EMAIL") = Request.Form("EMAILS")
: rsAddComments.Fields("SUBUNITDEPT") = Request.Form("DEPTS")
: rsAddComments.Fields("SUBUNITDES") = Request.Form("DESCS")
: rsAddComments.Fields("BUILDINGNAME") = Request.Form("BNAME")
: rsAddComments.Fields("PHONENUMBER") = Request.Form("PHONE")
: rsAddComments.Fields("CUBENUMBER") = Request.Form("CUBE")
: rsAddComments.Fields("MAILCODE") = Request.Form("MAILC")
: rsAddComments.Fields("FLOOR") = Request.Form("FLOORS")
: rsAddComments.Fields("CELLPHONE") = Request.Form("requiredCELLS")
: rsAddComments.Fields("FAXNUMBER") = Request.Form("FAX")
: rsAddComments.Fields("PAGERNUMBER") = Request.Form("PAGER")
: rsAddComments.Fields("TITLE") = Request.Form("TITL")
: rsAddComments.Fields("CONTRACTHO") = Request.Form("EMPLOYER")
: rsAddComments.Fields("CLASSIFICATION") = Request.Form("CLIF")
: rsAddComments.Fields("WHOLENAME") = Request.Form("WHOLE")
: rsAddComments.Fields("STREETADDRESS") = Request.Form("ADDY")
: rsAddComments.Fields("CITY") = Request.Form("CITIES")
: rsAddComments.Fields("STATE") = Request.Form("STATES")
: rsAddComments.Fields("ZIP") = Request.Form("ZIPS")
: rsAddComments.Fields("OFFICEPHONEEXT") = Request.Form("OFFPH")
: rsAddComments.Fields("SUBACCOUNT") = Request.Form("SUBACC")
: rsAddComments.Fields("HANDSETMAKE") = Request.Form("HMAKE")
: rsAddComments.Fields("HANDSETMODEL") = Request.Form("HMODEL")
: rsAddComments.Fields("ADMINRIGHTS") = Request.Form("ARIGHTS")
: rsAddComments.Fields("MANAGEDDEPT") = Request.Form("MGED")
: rsAddComments.Fields("IME") = Request.Form("IMEIESN")
: rsAddComments.Fields("FLEET") = Request.Form("FLT")
: rsAddComments.Fields("MEMBERNUMBER") = Request.Form("MEMNUM")
: rsAddComments.Fields("RATEPLAN") = Request.Form("RPLAN")
: rsAddComments.Fields("USEDAS") = Request.Form("USED")
: rsAddComments.Fields("VENDOR") = Request.Form("VNDR")
: rsAddComments.Fields("SERVICE") = Request.Form("SRVC")
: rsAddComments.Fields("NOTES") = Request.Form("note")
:
: rsAddComments.Update
:
: rsAddComments.Close
: Set rsAddComments = Nothing
: Set adoCon = Nothing
:
: Response.Redirect "DatabaseSelect.asp"
:
: End If
: %>

Message #5 by "Ken Schaefer" <ken@a...> on Wed, 21 Aug 2002 10:49:10 +1000
You mean:

If rsAddComments.EOF then
    ' Call AddNew
Else
    ' Redirect
End if

I think Robert wanted to redirect if the record alreay exists.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Darrell" <darrell@b...>
Subject: [access_asp] RE: Adding Duplicates help


: Hi Robert
:
: You are going about this the wrong way.
:
: Do a simple end of file check as follows:
:
: if rsAddComments.EOF then    'If the cellular phone number is not found
this
: will be true
: response.redirect "wherever.asp"
: else
: rsAddComments.AddNew
:
:
: Cheers
: Darrell
:
: -----Original Message-----
: From: Robert Boczkay [mailto:rboczkay@e...]
: Sent: 20 August 2002 14:51
: To: Access ASP
: Subject: [access_asp] Adding Duplicates help
:
:
: I have a webpage that allows a user to add to the database.  If the
: database already has a record with that cell phone number in it, I want it
: to redirect to another page.  I have been trying multiple ways of doing
: this for 2 weeks now and cannot figure it out.  I would greatly appreciate
: it if someone could help me . Thanks!  Here is my code:
:
: <%
: 'If the session variable is False or does not exsist then redirect the
: user to the unauthorised user page
: If Session("TADA") = False or IsNull(Session("TADA")) = True then
:
:  'Redirect to unathorised user page
:  Response.Redirect"unauthorised_user_page.htm"
: End If
: %>
:
: <%
: 'Dimension variables
: Dim adoCon
: Dim rsAddComments
: Dim strSQL
: Dim Errortime
: Dim newSQL
: Dim cellular
: Dim cellvar
:
: Errortime = False
: celluar = Request.Form("requiredCELLS")
:
: Set adoCon = Server.CreateObject("ADODB.Connection")
:
: adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
: Server.MapPath("\FORMYEYESONLY\db\database.mdb")
:
: Set rsAddComments = Server.CreateObject("ADODB.Recordset")
:
: 'strSQL = "SELECT Master_List.* FROM Master_List;"
: strSQL = "SELECT Master_List.* FROM Master_List WHERE
: Master_List.CELLPHONE ='" & cellular & "'"
:
: rsAddComments.CursorType = 2
:
: rsAddComments.LockType = 3
:
: rsAddComments.Open strSQL, adoCon
:
: If strSQL = TRUE Then
:
:      Response.Redirect "http://www.yahoo.com"
:
: Else
:
: rsAddComments.AddNew
:
: rsAddComments.Fields("LASTNAME") = Request.Form("LAST")
: rsAddComments.Fields("FIRSTNAME") = Request.Form("FIRST")
: rsAddComments.Fields("MID") = Request.Form("MIDDLE")
: rsAddComments.Fields("NETID") = Request.Form("NET")
: rsAddComments.Fields("EMAIL") = Request.Form("EMAILS")
: rsAddComments.Fields("SUBUNITDEPT") = Request.Form("DEPTS")
: rsAddComments.Fields("SUBUNITDES") = Request.Form("DESCS")
: rsAddComments.Fields("BUILDINGNAME") = Request.Form("BNAME")
: rsAddComments.Fields("PHONENUMBER") = Request.Form("PHONE")
: rsAddComments.Fields("CUBENUMBER") = Request.Form("CUBE")
: rsAddComments.Fields("MAILCODE") = Request.Form("MAILC")
: rsAddComments.Fields("FLOOR") = Request.Form("FLOORS")
: rsAddComments.Fields("CELLPHONE") = Request.Form("requiredCELLS")
: rsAddComments.Fields("FAXNUMBER") = Request.Form("FAX")
: rsAddComments.Fields("PAGERNUMBER") = Request.Form("PAGER")
: rsAddComments.Fields("TITLE") = Request.Form("TITL")
: rsAddComments.Fields("CONTRACTHO") = Request.Form("EMPLOYER")
: rsAddComments.Fields("CLASSIFICATION") = Request.Form("CLIF")
: rsAddComments.Fields("WHOLENAME") = Request.Form("WHOLE")
: rsAddComments.Fields("STREETADDRESS") = Request.Form("ADDY")
: rsAddComments.Fields("CITY") = Request.Form("CITIES")
: rsAddComments.Fields("STATE") = Request.Form("STATES")
: rsAddComments.Fields("ZIP") = Request.Form("ZIPS")
: rsAddComments.Fields("OFFICEPHONEEXT") = Request.Form("OFFPH")
: rsAddComments.Fields("SUBACCOUNT") = Request.Form("SUBACC")
: rsAddComments.Fields("HANDSETMAKE") = Request.Form("HMAKE")
: rsAddComments.Fields("HANDSETMODEL") = Request.Form("HMODEL")
: rsAddComments.Fields("ADMINRIGHTS") = Request.Form("ARIGHTS")
: rsAddComments.Fields("MANAGEDDEPT") = Request.Form("MGED")
: rsAddComments.Fields("IME") = Request.Form("IMEIESN")
: rsAddComments.Fields("FLEET") = Request.Form("FLT")
: rsAddComments.Fields("MEMBERNUMBER") = Request.Form("MEMNUM")
: rsAddComments.Fields("RATEPLAN") = Request.Form("RPLAN")
: rsAddComments.Fields("USEDAS") = Request.Form("USED")
: rsAddComments.Fields("VENDOR") = Request.Form("VNDR")
: rsAddComments.Fields("SERVICE") = Request.Form("SRVC")
: rsAddComments.Fields("NOTES") = Request.Form("note")
:
: rsAddComments.Update
:
: rsAddComments.Close
: Set rsAddComments = Nothing
: Set adoCon = Nothing
:
: Response.Redirect "DatabaseSelect.asp"
:
: End If
: %>
:
:


  Return to Index