Results 1 to 12 of 12

Thread: [RESOLVED] <Resolved> what's wrong with this???

  1. #1

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Resolved [RESOLVED] <Resolved> what's wrong with this???

    Hey u all...
    I have recently started using JS on ASP, but somewhere something went wrong: I could'nt compare two strings!!
    Code:
    <%@ LANGUAGE = JScript %>
    <html>
    <%var tester = (Request.QueryString("t")), oConn, oRs, filePath, r,i=1,b=false;
    filePath = Server.MapPath("pics.mdb");
    oConn = Server.CreateObject("ADODB.Connection");
    r = Server.CreateObject("adodb.recordset");
    oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath);
    oRs = oConn.Execute("SELECT * From TableList");
    while (!oRs.eof) {
    b=b||(tester==oRs("name"));
    Response.Write(oRs("name") + ": " + b + "<BR> " );
    if (b) break;
    oRs.MoveNext();}
    oRs.close();
    if (b){
    Response.Write("<B>" +tester +" is valid!!</b>");
    }else{
    Response.Write(tester+ " is invalid!!");}%>
    My server's response is always invalid, even if ?t='s value is in the table.
    What should I do??
    Last edited by Lemon Lime; Sep 5th, 2005 at 11:49 AM. Reason: resolved
    I've had enough with sainity!
    What's the use of it anyway?

  2. #2
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: what's wrong with this???

    Having no knowledge of ASP what so ever...

    b=b||(tester==oRs("name"));

    Whats that? Shouldn't there be an if statement there?
    Don't Rate my posts.

  3. #3

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: what's wrong with this???

    I write codes like this for ages! it means that every loop b flag will turn on if oRs("name") and tester are the same and stays on.
    The problem is that no matter what, b will stay false, even if they are the same (by value).
    Writting like this is the same as
    Code:
    if (oRs("name") == tester) b=true; else b=false;
    But if the next time oRs("name") is not identical to tester b will be false so b is false in the beginning, after checking up equivalency just use OR operator like this:
    Code:
    if (oRs("name") == tester) b=true; else b=false ||b;
    Well, (oRs("name") == tester) is a logical statement, so what's the differance?

    Know what? even
    Code:
    b||=(tester==oRs("name"));
    should have work the same.

    Am I missing something?
    I've had enough with sainity!
    What's the use of it anyway?

  4. #4

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Oops: what's wrong with this???

    Know what? even
    b||=(tester==oRs("name"));
    should have work the same.
    Ooops, it does'nt work.... but
    Code:
    b=b||(tester==oRs("name"));
    does.
    Huge Oops....
    I've had enough with sainity!
    What's the use of it anyway?

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: what's wrong with this???

    There's no ||= operator.

    Anyway, are you sure oRs("name") yields something meaningful? If it's an array, the array index operator in JScript is [].
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: what's wrong with this???

    Hey CornedBee!
    The oRs("name") is a record on my table. as you can see on the source
    Code:
    oConn = Server.CreateObject("ADODB.Connection");
    r = Server.CreateObject("adodb.recordset");
    oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath);
    oRs = oConn.Execute("SELECT * From TableList")
    That's not the problem! The problem starts when I'm trying to compare texts in the line b=b|| ....
    I've had enough with sainity!
    What's the use of it anyway?

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: what's wrong with this???

    I'm questioning the use of ().
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: what's wrong with this???

    Quote Originally Posted by CornedBee
    I'm questioning the use of ().
    When I tried using [] like so: oRs["name"] i got undefined.
    The usage for data from ADODB inside records is oRs("name").
    I've had enough with sainity!
    What's the use of it anyway?

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: what's wrong with this???

    Nevertheless, try this for a moment:
    Code:
    while (!oRs.eof) {
    var name = oRs("name");
    // Output name and typeof(name) here.
    b=b||(tester==name);
    I wonder what those are.



    Oh, and might I mention how wrong it is to write the existence test in the script in the first place? Put the query in the SQL.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: what's wrong with this???

    CornedBee dude!!
    both of them are Objects
    I've changed a bit the code and still nothing:
    Code:
    <%@language =javascript%>
    <html>
    <%var tester = " ", tester2 = " ", oConn, oRs, filePath, r,i=1,b=false;
    tester = (Request.QueryString("t"));
    filePath = Server.MapPath("pics.mdb");
    oConn = Server.CreateObject("ADODB.Connection");
    r = Server.CreateObject("adodb.recordset");
    oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath);
    oRs = oConn.Execute("SELECT * From TableList");
    while (!oRs.eof) {
    tester2 = oRs("name");
    Response.Write("tst:"+(tester==tester2)+" ");
    Response.Write(typeof(oRs("name")) + "**  " );
    Response.Write(typeof(tester) + "@@  ");
    Response.Write(typeof(tester2) + "##  ");
    b=b||(tester==tester2);
    Response.Write(tester2 + ": " + b + "<BR> ");
    if (b) break;
    oRs.MoveNext();}
    oRs.close();
    if (b){
    Response.Write("<B>" +tester +" is valid!!</b>");
    }else{
    Response.Write(tester+ " is invalid!!");}%>
    my screen looks like this:
    address:123.asp?t=yeshiva
    Code:
    tst:false object** object@@ object## yeshiva: false
    tst:false object** object@@ object## volunteering: false
    yeshiva is invalid!!
    Any ideas?
    I've had enough with sainity!
    What's the use of it anyway?

  11. #11
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: what's wrong with this???

    Wait a moment, everything is an object there? Ugh!

    OK, after browsing the docs, I'm not one bit smarter. All code examples are in VBScript, which makes it somewhat tiresome.
    Have you tried calling toString() on the objects?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  12. #12

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Resolved Resolved: what's wrong with this???

    Code:
    <%@language =javascript%>
    <html>
    <%var tester = " ",oConn, oRs, filePath, r,i=1,b=false;
    tester = new String((Request.QueryString("t")));
    filePath = Server.MapPath("pics.mdb");
    oConn = Server.CreateObject("ADODB.Connection");
    r = Server.CreateObject("adodb.recordset");
    oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath);
    oRs = oConn.Execute("SELECT * From TableList");
    while (!oRs.eof) {
    b=b||(tester.toLowerCase( )==oRs("name").value.toLowerCase( ));
    if (b) break;
    oRs.MoveNext();}
    oRs.close();
    if (b){
    Response.Write("<B>" +tester +" is valid!!</b>");
    }else{
    Response.Write(tester+ " is invalid!!");}%>
    THAT'S IT
    .value is the answer
    debugged it twice!!
    I've had enough with sainity!
    What's the use of it anyway?

Posting Permissions

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



Click Here to Expand Forum to Full Width