Results 1 to 3 of 3

Thread: Novice

  1. #1
    ASP Novice Guest

    Default Novice

    I am editing an asp driven web site with an asp page that allows users to enter records to be stored in an Access database. Is there a way on the ASP page end (vbscript or javascript) that can stop a record from being passed through to the database twice? Or does the database itself need to be set up with "primary field(s)" to elimiate the chance of duplicate records being entered? Please respond to<BR><BR>Thanks<BR><BR>Novice<BR>dmsi@e

  2. #2
    This should work Guest

    Default RE: Novice

    Just do a quick SQL search first on the table to see if the information is already there.<BR><BR>StrName=Request.form("Name")<BR>StrS treet=Request.form("Name")<BR>StrCity=Request.form ("Name")<BR><BR>Example: Sql="Select * from table where table.Name=&#039" & StrName & "&#039 and Table.Street=&#039" & StrStreet & "&#039 And Table.City=&#039" & StrCity & "&#039"<BR>RS.Open Sql,YourConnection,1,1<BR>MyCnt=RS.recordcount<BR> RS.close<BR>set rs=nothing<BR><BR>if MyCnt&#062;0 Then<BR>response.write "This information is currently in the database&#060;P&#062; Click the back button to return to the submission form"<BR>end if<BR>if its not there then it will go oln to the insert code else it will stop<BR>

  3. #3
    57Chevy Guest

    Default There is a COUNT aggregate function, y'know

    yeah, or you &#060;i&#062;could&#060;/i&#062; use the COUNT function, as in <BR><BR>SELECT COUNT(*)FROM Table <BR>WHERE Table.Name =&#039" & strWhatever "&#039"<BR><BR>etc.<BR> - and continue as described in previous post, as far as building the query string is concerned. Then do<BR><BR>myCnt = RS(0)<BR><BR>and continue as above. Should work :)

Posting Permissions

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