How do I search through rows?

Results 1 to 3 of 3

Thread: How do I search through rows?

  1. #1
    Join Date
    Dec 1969

    Default How do I search through rows?

    I know how to search down the columns of a table to find a particular item (password). When that password is found, I want to search through the row that password is located in to find another item. How do I do this? I hope I'm making sense here.

  2. #2
    Join Date
    Dec 1969

    Default Use sql select statement

    To locate a row with a certain password and some value in an other column you can use code along these lines. (Assuming that password and the other item is fetched from a form and guessing what names you have in your db.)<BR><BR>set connect = server.createobject("adodb.connection")<BR>connect .open "connectionstring"<BR><BR>pwd = request.form("pwd")<BR>oI = request.form("otheritem")<BR>query = "select * from users where pwd = &#039;" & replace(pwd,"&#039;","&#039;&#039;") & "&#039; and otherItem = &#039;" & replace(oi,"&#039;","&#039;&#039;") & "&#039;"<BR>set rs = connect.execute(query)<BR>if rs.eof then<BR> &#039;no rows fulfilled criteria<BR>else<BR> &#039;row found<BR>end if<BR><BR><BR>I also assumed that both columns are defined as character. If any is numric it should be any &#039; surrounding the value.

  3. #3
    Join Date
    Dec 1969

    Default RE: Use sql select statement

    that is when you know the field name... for some reason i thought that you didn&#039;t know the field in which the password is, if that is the case then you can do this<BR><BR>SET rs1 = conn.execute("SELECT TOP 1 * FROM tblTable") <BR>&#039; this returns the first record (and the field names) alternatively you could do<BR>SET rs1 = conn.execute("SELECT * FROM tblTable WHERE theId=-1") <BR><BR>for each fieldName in rs1.Fields<BR> theFName = fieldName.Name<BR> strSql = "SELECT COUNT(*) AS theCount FROM theTable WHERE "<BR> strSQL = strSql & theFName & "=&#039;" & pwd & "&#039;"<BR><BR> &#039;execute sql here<BR><BR> &#039;check if count is greater than 0 and if count is greater than 0<BR><BR> strSql = "SELECT *theFieldList* FROM theTable WHERE "<BR> strSQL = strSql & theFName & "=&#039;" & oI & "&#039;"<BR><BR> &#039;execute<BR>next

Posting Permissions

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