checking names in a database

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

  1. #1

    Default checking names in a database

    Hi all,

    I have an asp page that accesses a database. The code below checks to make
    sure that a username and their full names do not already exist in the
    database. I am relatively new to ADO.

    The first group returns an answer, the second code group, when inserted
    causes an error.
    What is a better alternative to this?

    (ps watch wrap)

    strSQL = "SELECT UserName FROM tblUser WHERE ((UserName='" & Name & "') AND
    (ID<>" & FormID & "))"
    MyRS.Open strSQL, MyCN, 3
    If MyRS.RecordCount > 0 Then Exist = True: EMode = True

    strSQL = "SELECT FullName FROM tblUser WHERE ((FullName='" & FName & "')
    AND (ID<>" & FormID & "))"
    MyRS.Open strSQL, MyCN, 3
    If MyRS.RecordCount > 0 Then Exist = True: EMode = True


    Cheers, Bill.


    William E Hatto Guest

  2. Similar Questions and Discussions

    1. Passing database column names as varable
      I've tried all night to figure this one out..And I can't seem to find the answear on the forums.. I've made a CustomTag-file that need these...
    2. Database table names
      In the database tab of the Application panel, when I go down the hierachy to the tables dreamweaver shows the full path instead of just the table...
    3. querying table names in a database
      Hey Gang - Anyone have a fast and easy CFQUERY that can query all the table names in an Access database? TIA
    4. Get database field names from table...
      How do you get the database fieldnames from a table and display them using cfquery and cfoutput. Thanks a million...
    5. Checking which version of Jet a database is using
      How do I tell which version of Jet particular Access 2000 database is using? I'm trying to use the proper OLE-DB settings to access it via ASP and...
  3. #2

    Default Re: checking names in a database

    What error?

    How about:

    strSQL = "SELECT UserName FROM tblUser WHERE (((UserName='" & Name & "' OR
    Fullname='" & FName & "') AND
    (ID<>" & FormID & "))"
    Set MyRS = MyCN.Execute(strSQL)
    EMode = Not MyRS.EOF
    MyRS.Close : Set MyRS = Nothing


    Not tested!

    Ray at work

    "William E Hatto" <xxnospamxxweh@bigpond.net.au> wrote in message
    news:eZnMEmvIEHA.364@TK2MSFTNGP11.phx.gbl...
    > Hi all,
    >
    > I have an asp page that accesses a database. The code below checks to make
    > sure that a username and their full names do not already exist in the
    > database. I am relatively new to ADO.
    >
    > The first group returns an answer, the second code group, when inserted
    > causes an error.
    > What is a better alternative to this?
    >
    > (ps watch wrap)
    >
    > strSQL = "SELECT UserName FROM tblUser WHERE ((UserName='" & Name & "')
    AND
    > (ID<>" & FormID & "))"
    > MyRS.Open strSQL, MyCN, 3
    > If MyRS.RecordCount > 0 Then Exist = True: EMode = True
    >
    > strSQL = "SELECT FullName FROM tblUser WHERE ((FullName='" & FName & "')
    > AND (ID<>" & FormID & "))"
    > MyRS.Open strSQL, MyCN, 3
    > If MyRS.RecordCount > 0 Then Exist = True: EMode = True
    >
    >
    > Cheers, Bill.
    >
    >

    Ray at Guest

  4. #3

    Default Re: checking names in a database

    P.S. Do you really expect to never have two people with the same name?
    There are many, many John Smiths in the world. Be careful with how you're
    doing this, because you may wind up mixing data together that belong to
    different people...

    Ray at work

    "William E Hatto" <xxnospamxxweh@bigpond.net.au> wrote in message
    news:eZnMEmvIEHA.364@TK2MSFTNGP11.phx.gbl...
    > Hi all,
    >
    > I have an asp page that accesses a database. The code below checks to make
    > sure that a username and their full names do not already exist in the
    > database. I am relatively new to ADO.
    >
    > The first group returns an answer, the second code group, when inserted
    > causes an error.
    > What is a better alternative to this?
    >
    > (ps watch wrap)
    >
    > strSQL = "SELECT UserName FROM tblUser WHERE ((UserName='" & Name & "')
    AND
    > (ID<>" & FormID & "))"
    > MyRS.Open strSQL, MyCN, 3
    > If MyRS.RecordCount > 0 Then Exist = True: EMode = True
    >
    > strSQL = "SELECT FullName FROM tblUser WHERE ((FullName='" & FName & "')
    > AND (ID<>" & FormID & "))"
    > MyRS.Open strSQL, MyCN, 3
    > If MyRS.RecordCount > 0 Then Exist = True: EMode = True
    >
    >
    > Cheers, Bill.
    >
    >

    Ray at Guest

  5. #4

    Default Re: checking names in a database

    On Thu, 15 Apr 2004 22:53:50 +0800, "William E Hatto"
    <xxnospamxxweh@bigpond.net.au> wrote:
    >Hi all,
    >
    >I have an asp page that accesses a database. The code below checks to make
    >sure that a username and their full names do not already exist in the
    >database. I am relatively new to ADO.
    >
    >The first group returns an answer, the second code group, when inserted
    >causes an error.
    And the error is...?

    Jeff
    >What is a better alternative to this?
    >
    >(ps watch wrap)
    >
    > strSQL = "SELECT UserName FROM tblUser WHERE ((UserName='" & Name & "') AND
    >(ID<>" & FormID & "))"
    > MyRS.Open strSQL, MyCN, 3
    > If MyRS.RecordCount > 0 Then Exist = True: EMode = True
    >
    > strSQL = "SELECT FullName FROM tblUser WHERE ((FullName='" & FName & "')
    >AND (ID<>" & FormID & "))"
    > MyRS.Open strSQL, MyCN, 3
    > If MyRS.RecordCount > 0 Then Exist = True: EMode = True
    >
    >
    >Cheers, Bill.
    >
    Jeff Cochran Guest

  6. #5

    Default Re: checking names in a database

    I am thinking that the only time i would check for a duplicate name, is if
    this was something that someone created a user name.. ie: nickname
    FP

    "Jeff Cochran" <jcochran.nospam@naplesgov.com> wrote in message
    news:407eb3f1.12290002@msnews.microsoft.com...
    > On Thu, 15 Apr 2004 22:53:50 +0800, "William E Hatto"
    > <xxnospamxxweh@bigpond.net.au> wrote:
    >
    > >Hi all,
    > >
    > >I have an asp page that accesses a database. The code below checks to
    make
    > >sure that a username and their full names do not already exist in the
    > >database. I am relatively new to ADO.
    > >
    > >The first group returns an answer, the second code group, when inserted
    > >causes an error.
    >
    > And the error is...?
    >
    > Jeff
    >
    > >What is a better alternative to this?
    > >
    > >(ps watch wrap)
    > >
    > > strSQL = "SELECT UserName FROM tblUser WHERE ((UserName='" & Name & "')
    AND
    > >(ID<>" & FormID & "))"
    > > MyRS.Open strSQL, MyCN, 3
    > > If MyRS.RecordCount > 0 Then Exist = True: EMode = True
    > >
    > > strSQL = "SELECT FullName FROM tblUser WHERE ((FullName='" & FName & "')
    > >AND (ID<>" & FormID & "))"
    > > MyRS.Open strSQL, MyCN, 3
    > > If MyRS.RecordCount > 0 Then Exist = True: EMode = True
    > >
    > >
    > >Cheers, Bill.
    > >
    >

    +FarmerPickles 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