1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need help with error messgage...

Discussion in 'C#' started by brossyg, May 12, 2010.

  1. #1
    I am trying to match a string on the server side of an ASP page. My code is this:
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <!-- #include file = "connection.asp" -->
    <!-- #include file = "replace.asp" -->
    
    <%
    var r_user;
    var r_pass;
    
    r_user = Request.querystring("xyz");
    r_pass = Request.querystring("abc");
    
    r_user = replaceAwithBinC("'","'",r_user + '');
    r_pass = replaceAwithBinC("'","'",r_pass + '');
    
    r_user = replaceAwithBinC('"',""",r_user + '');
    r_pass = replaceAwithBinC('"',""",r_pass + '');
    
    var quer = "SELECT access_code FROM resourceadmin WHERE (user_name = '" + r_user + "') AND (user_pass = '" + r_pass + "')";
    var rs = Server.CreateObject("ADODB.RecordSet");
    rs.Open(quer,con);	
    
    var access = rs("access_code");
    Response.Write(access);
    
    if(access.indexOf("wc")<0) {
    	Response.Write("Yes");
    }
    else{
    	Response.Write("No");
    }
    
    rs.Close();
    rs = null;
    
    con.Close();
    con = null;
    %>
    Code (markup):
    This gets a Username and Password from a URL link, gets the "access_code" from the Access database for that subscriber and then I am trying to match the access code for the letters "wc".

    It works fine until it tries to match the string "wc" to the access code. The variable "access" properly appears as 999, so the match should return "No".

    However, I get an "Object doesn't support this property or method" error for the line that has the if(access.indexOf("wc")<0) statement on it. I have tried using InStr(), but that doesn't work either.

    Please help! I don't know why I am getting this error. Thanks.
     
    brossyg, May 12, 2010 IP
  2. nyxano

    nyxano Peon

    Messages:
    417
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I am guessing that access.indexOf("wc") is being considered a "string" and therefore, a string can not be < 0. Have you tried INT(access.indexOf("wc")) or CInt(access.indexOf("wc")) or CDbl(access.indexOf("wc")) to see if the error message goes away? I am not familiar with the indexOf property so this is just a guess on my part.
     
    nyxano, May 12, 2010 IP
  3. brossyg

    brossyg Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I just tired all of your suggestions and none made a difference, but it did inspire me to declare the variable as a string like this:

    var access = new String(rs("access_code"));
    Code (markup):
    which works perfectly...THANKS!
     
    brossyg, May 12, 2010 IP