Results 1 to 13 of 13
  1. #1
    Join Date
    Oct 2001
    Posts
    92

    This code ( ASP )

    I have this code that i use to query my database to pull out customers email addresses, however i am trying to get it to pull out email accounts from a whole list of domain names ( i.e from a comma seperated values e.g domain1.com, domain2.com )

    So that i can do a bulk search and get bulk results as

    domain1.com [email protected]
    domain1.com [email protected] :-)


    ---------------------------here is the current code--------------------------

    <%
    var-domain = Request.Querystring("domain-name")

    SQL="SELECT email FROM requests WHERE domain = '" & var-domain & "'"
    Set connb = server.createobject("ADODB.Connection")
    connb.open "some-connection"
    set user = connb.execute(SQL)

    Do UNTIL user.EOF
    var-email=user.Fields("email")

    %>

    <p><b><%-var-domain %> sdasda</b></p>

    <% user.MoveNext
    Loop
    connb.close %>
    -----------------------------------------------------------------------------------
    "I believe there is a global need for perhaps five computers."
    (Thomas Watson, IBM boss, 1943)

  2. #2
    Join Date
    Sep 2002
    Location
    Dallas, TX
    Posts
    205
    If I understand you correctly, you could just dynamically build your SQL query string adding the domains you want to lookup to the WHERE clause. You would end up with something like:

    SELECT....
    FROM...
    WHERE domain = 'domain1' OR domain = 'domain2' OR domain = 'domain3' OR domain = 'domain4'...etc, etc, etc.
    justin 'at' abrogo.com
    http://www.abrogo.com
    Shared Unix Hosting

  3. #3
    <%
    var-domain = Request.Querystring("domain-name")

    SQL="SELECT email FROM requests WHERE domain = '" & var-domain & "'"
    Set connb = server.createobject("ADODB.Connection")
    connb.open "some-connection"
    set user = connb.execute(SQL)

    Do UNTIL user.EOF
    var-email=user.Fields("email")

    %>

    <p><b><%=var-domain %> <%=var-email%></b></p>

    <% user.MoveNext
    Loop
    connb.close %>
    Last edited by tdavis; 10-28-2002 at 12:05 PM.

  4. #4
    the above should work if you want to do 1 domain at a time...but if you want to pull the data from each of the domains all at once you will just need to change your sql query to something like:

    SQL="SELECT * FROM requests ORDER BY domain ASC"

  5. #5
    Join Date
    Oct 2001
    Posts
    92

    so far

    Hi

    Thanks fo rth e feedback guy/gals, however i think you have mis-understood.

    I am not trying to pull out all the domain names from the table that match a certain criteria...see below

    TABLE
    --------

    domain name email address
    ----------------- ------------------

    domain1.com [email protected]

    domain2.com [email protected]

    domain3.com [email protected]


    >>>

    I want to have a form where is fill in say

    -----------------------------------------------
    Search : domain1.com, domain2.com
    -----------------------------------------------

    So i want to

    a) parsethe comma seperated values from this from field

    b) run 1 SQL query that will return the 2 email accounts

    So esssentially i want to be able to type in say 100 domain names in one search box, run an SQL query that will return a result like

    Domain1.com [email protected]
    domain23.com [email protected]


    All in one search so i dont have to search one domain at a time to get the email value
    "I believe there is a global need for perhaps five computers."
    (Thomas Watson, IBM boss, 1943)

  6. #6
    Join Date
    Sep 2002
    Location
    Dallas, TX
    Posts
    205
    The code I gave you will work. You just have to parse the list of domains you are sent and dynamically build the SQL query string.

    There is also the IN statement. Where you can state...

    WHERE domain IN ('domain1', 'domain2'...

    However, I can't remember whether or not you can use string literals or just ordinal values. It also might work just in MS SQL Server.

    When I get a bit more time later, I'll check for sure.
    justin 'at' abrogo.com
    http://www.abrogo.com
    Shared Unix Hosting

  7. #7
    Join Date
    Oct 2001
    Posts
    92

    the code sofar

    Here is what i have come up with, but not being an ASP guy, its biggy, i get "expected end" in the last line 19

    -------------------------------------------------

    <%
    dim accountv, sql, conn, adors
    accountv = trim(replace(Request.QueryString("account"), "'", "''"))
    sql = "SELECT email FROM users WHERE account = '" & accountv & "'"
    set conn = Server.CreateObject("ADODB.Connection")
    adors = Server.CreateObject("ADODB.Recordset")
    conn.ConnectionString = "something"
    conn.Open
    adors.ActiveConnection = conn
    adors.Open(sql)
    With Response
    Do Until adors.EOF
    .Write "E-Mail:" & adors("email") & " " & accountv & "<br>"
    .Write adors.MoveNext
    Loop

    adors.Close
    Set adors = Nothing
    conn.Close
    Set conn = Nothing
    %>

    --------------------------------------
    "I believe there is a global need for perhaps five computers."
    (Thomas Watson, IBM boss, 1943)

  8. #8

    so basically?

    I'm not a hosting expert yet, but when it comes to ASP code, I can help.

    The problem you are having is actually simple (as most code errors turn out to be in the end)

    you forgot to end your with, so simply add it like this:



    <%
    dim accountv, sql, conn, adors
    accountv = trim(replace(Request.QueryString("account"), "'", "''"))
    sql = "SELECT email FROM users WHERE account = '" & accountv & "'"
    set conn = Server.CreateObject("ADODB.Connection")
    adors = Server.CreateObject("ADODB.Recordset")
    conn.ConnectionString = "something"
    conn.Open
    adors.ActiveConnection = conn
    adors.Open(sql)
    With Response
    Do Until adors.EOF
    .Write "E-Mail:" & adors("email") & " " & accountv & "<br>"
    .Write adors.MoveNext
    Loop

    '//HERE
    End With
    '//THAT'S ALL

    adors.Close
    Set adors = Nothing
    conn.Close
    Set conn = Nothing
    %> End With

  9. #9
    Join Date
    Oct 2001
    Posts
    92

    Smile i am getting there

    Thanx gmcarraway

    that fixed it, now new bug:: line 9

    Object doesn't support this property or method: 'ActiveConnection'

    "I believe there is a global need for perhaps five computers."
    (Thomas Watson, IBM boss, 1943)

  10. #10
    sorry about that extra End Width at the end. looking at your code now for the other bug...

  11. #11
    ... ok no problem...

    add the word "set" before this line: adors = Server.CreateObject("ADODB.Recordset")

    so that it reads:

    set adors = Server.CreateObject("ADODB.Recordset")

    let me know...

  12. #12
    Join Date
    Oct 2001
    Posts
    92

    error lives on :-(

    the same error still comes up for this
    "I believe there is a global need for perhaps five computers."
    (Thomas Watson, IBM boss, 1943)

  13. #13
    try putting "set" in front of

    adors.ActiveConnection = conn

    so it reads

    set adors.Activeconnection = conn

    if that doesn't work, you MIGHT try adding set here to:

    set conn.ConnectionString = "someting"

    let me know...

Posting Permissions

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