Results 1 to 3 of 3

Thread: Validation

  1. #1
    Join Date
    Dec 1969

    Default Validation

    I want to try and validate the primary key value - ensuring that the administrator cannot provide a value that already exists in the database.The code that I am trying to use is as follows:<BR><BR>&#060;%<BR>Dim SQL<BR>Dim RSID<BR><BR>Dim ID<BR>ID = UCase(TRIM(Request.Form("txtid")))<BR><BR>If ID &#060;&#062; "" Then<BR><BR>&#039;Select Statement to take the IDs that <BR>&#039;already exist in the database<BR>SQL = "SELECT C_ID FROM User WHERE C_ID = &#039;"&ID&"&#039;"<BR><BR>&#039;Execute the SQL Statement<BR>Set RSID = connection.Execute(SQL)<BR><BR> If not RSID.EOF Then<BR> Response.Write("&#060;script&#062; alert(&#039;That ID already exists&#039;);&#060;/script&#062;")<BR> End If<BR>End If<BR>%&#062;<BR><BR>How can I get this piece of code to be called??<BR>

  2. #2
    Join Date
    Dec 1969

    Default Check my 'similar subject..' post above

    Sorry Karen that was menat to be linked here.

  3. #3
    Join Date
    Dec 1969

    Default RE: Two things....

    I might change to this:<BR>SQL = "SELECT C_ID FROM User WHERE C_ID = "& ID<BR>&#039; If it&#039;s an int no need for &#039; around it.<BR>Also do a Response.Write on ID to make a value is being passed.<BR><BR><BR><BR>Second-<BR>Why not:<BR>SQL = "SELECT C_ID FROM User"<BR>Set RSID = connection.Execute(SQL)<BR>RSID.MoveLast<BR>Dim ID<BR>ID = Int(RSID +1)<BR><BR>For the admin to assign id&#039;s.<BR><BR><BR>If you are still getting error post it.<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