Duplicate Field Entry on Database Question

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Duplicate Field Entry on Database Question

    Hi all,

    Ok I guess this is quite a simple thing to do but as an SQL/ASP newbie
    im having trouble getting my head around it.

    I have a simple form which users submit via a querystring. This is
    sent to an asp page which inserts the data into a SQL database. All
    that I want do is check one of the strings against a database field to
    see if it already exists. If it does I want to set another string to a
    certain value ("idalreadyexists = 1") and then carry on writing to the
    strings into the database.
    I just cant work out how to phrase a query that checks the database
    and compares it to a string. Below is a very simplified example of
    what I have at the moment. Any help would be *much* appreciated!

    set objConn = Server.CreateObject("ADODB.Connection")
    strConnection = "DSN=ax;Database=ax;"
    strConnection = strConnection & "UID=sa;PWD=****;"
    objConn.Open strConnection

    strq = "INSERT INTO Main (id, email, password, idalreadyexists)VALUES
    "
    strq = strq & "('" & id &"', '" & email &"', '" & password &"', '" &
    idalreadyexists &"' )"
    objConn.Execute strQ

    Thanks
    Collaterly Sisters Guest

  2. Similar Questions and Discussions

    1. Comparing current field data with last entry for field
      Hi. I have a form that is inserting sales data on a daily basis. I have a field named "RoundTOTAL" which is the total sales for the day rounded to...
    2. Formated Entry Field
      Hi, I'm working on an application and I need a formated entry field for partnumbers following a specific mask. I don't want to hardcode the mask...
    3. Controls like IE URL entry field
      Dear all I need to design a control like IE URL entry field. When I type "http://www.a" in URL, all the addresses have "http://www.a" would...
    4. Linking date field to text field entry
      Is there a way to setup a date field that will automatically enter the date when any information is entered into a field next to it?
    5. field entry
      Hello, I want enter data into a field in filemaker but have it displayed as asterisks. I know that there are several plug-ins that will allow...
  3. #2

    Default Re: Duplicate Field Entry on Database Question



    "Collaterly Sisters" <jonner2004@hotmail.com> wrote in message
    news:c0f756cb.0311060412.243810e6@posting.google.c om...
    > Hi all,
    >
    > Ok I guess this is quite a simple thing to do but as an SQL/ASP newbie
    > im having trouble getting my head around it.
    >
    > I have a simple form which users submit via a querystring. This is
    > sent to an asp page which inserts the data into a SQL database.

    You may want consider using method=POST on your form.

    > All
    > that I want do is check one of the strings against a database field to
    > see if it already exists. If it does I want to set another string to a
    > certain value ("idalreadyexists = 1") and then carry on writing to the
    > strings into the database.
    > I just cant work out how to phrase a query that checks the database
    > and compares it to a string. Below is a very simplified example of
    > what I have at the moment. Any help would be *much* appreciated!


    Something like this:
    'checking for e-mail duplications

    set objConn = Server.CreateObject("ADODB.Connection")
    strConnection = "DSN=ax;Database=ax;" '''can you use a connection string
    here instead?
    strConnection = strConnection & "UID=sa;PWD=****;"
    objConn.Open strConnection

    bEmailExists = objConn.Execute("SELECT COUNT([email]) FROM [Main] WHERE
    [email]='" & email & "'").Fields.Item(0).Value > 0
    strq = "INSERT INTO Main (id, email, password, idalreadyexists)VALUES"
    strq = strq & "('" & id &"', '" & email &"', '" & password &"', '" &
    Abs(CInt(bEmailExists)) &"' )"

    ''The abs(cint( stuff will convert your True/False into 1/0.


    You could also do this all in a stored procedure or setup a trigger to check
    for duplicates and update the field accordingly.

    Ray at work





    >
    > set objConn = Server.CreateObject("ADODB.Connection")
    > strConnection = "DSN=ax;Database=ax;"
    > strConnection = strConnection & "UID=sa;PWD=****;"
    > objConn.Open strConnection
    >
    > strq = "INSERT INTO Main (id, email, password, idalreadyexists)VALUES
    > "
    > strq = strq & "('" & id &"', '" & email &"', '" & password &"', '" &
    > idalreadyexists &"' )"
    > objConn.Execute strQ
    >
    > Thanks

    Ray at Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139