Strange apostrophy and boolean problem

Results 1 to 2 of 2

Thread: Strange apostrophy and boolean problem

  1. #1
    Join Date
    Dec 1969

    Default Strange apostrophy and boolean problem

    ASP using SQL 7. When someone enters a new tour name, my script checks to see if it&#039;s already in the database. Works fine unless you enter an apostrophy. Then it tells you that that name already exists, which is wrong. I tried to debug and found an even more interesting question. How can a "If NOT objRs.EOF" print out a debug message ("filled") and a "If objRs.EOF" right after it also print out a debug message ("empty"). There must be some subtletly that I&#039;m missing about EOF. Very cryptic, can someone help? Here&#039;s the relevent snippet of code. Note that it prints out both "filled" and "empty". Note: that "update" is used to delineate between a new record (where under no circumstances will it accept a name that is already in the database) AND an existing record that is being modified (where it WILL except the same name if tourID is the same.<BR><BR><BR>nametest="true"<BR>sql2="SELECT tourName, tourID FROM tourOverall WHERE tourName=&#039;" & tourName & "&#039;"<BR>Set objConn2 = Server.CreateObject("ADODB.Connection")<BR>objConn 2.Open Application("connection")<BR>set objRS2 = Server.CreateObject("ADODB.Recordset")<BR>objRS2.O pen sql2, objConn2<BR>If objRS2.EOF Then<BR>Response.Write "empty"<BR>End If<BR>If NOT objRS2.EOF AND update = "no" Then<BR> Response.Write "filled"<BR> nametest="false"<BR>ElseIf NOT objRS2.EOF AND update = "yes" Then<BR> Do While NOT objRS2.EOF<BR> If tourID &#060;&#062; objRS2("tourID") AND tourName=objRS2("tourName")Then<BR> nametest="false"<BR> End If<BR> objRS2.MoveNext<BR> Loop<BR> <BR>End If<BR>objRS2.Close<BR>objConn2.Close

  2. #2
    Join Date
    Dec 1969

    Default I'd say that was impossible...

    ...if you hadn&#039;t shown the code so clearly.<BR><BR>Maybe it is the precedence of NOT???<BR><BR>How about we rewrite that slightly:<BR><BR>If Not objeRS2.EOF Then<BR> If update = "no" Then<BR> Response.Write "filled"<BR> nametext = "false"<BR> Else<BR> Do While ...<BR> ...<BR> Loop<BR> End If<BR>End If<BR><BR>???<BR><BR>Try that and see what it does?<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts