Urgent help needs from all DP members who r expert in ASP

Discussion in 'C#' started by datasolution, Jul 2, 2007.

  1. #1
    Hi Guys,
    I need urgent help needs from all DP members who r expert in ASP & SQL.

    I‘m using like statement of sql server in asp but value of variable does not retrieve to access a particular record from database. Here is asp:

    Please check this code and try to sort out this problem…
    Is there any error in code or there is something missing…

    Thanks in advance…
    :)
     
    datasolution, Jul 2, 2007 IP
  2. stugs

    stugs Peon

    Messages:
    157
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    response.write(rs("oneofyourfieldnames"))
    
    Code (markup):
    Replace oneofyourfieldnames with one of the fields in the table. Since you're doing a select * I dunno what any of the field names are.

    Anything?
     
    stugs, Jul 2, 2007 IP
  3. N_F_S

    N_F_S Active Member

    Messages:
    2,475
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Try :

    Set rs=con.execute ("select * from items where model like '%"&tval&"%';")
    Code (markup):
    When using LIKE statement you need the percentage signs.
     
    N_F_S, Jul 2, 2007 IP
  4. Bishop81

    Bishop81 Peon

    Messages:
    757
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Make sure you put spaces between the & and the surrounding characters...

    '" & tval & "'
     
    Bishop81, Jul 14, 2007 IP
  5. N_F_S

    N_F_S Active Member

    Messages:
    2,475
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    90
    #5
    that doesnt matter and will not change anything. You can have it with spaces or without.
     
    N_F_S, Jul 15, 2007 IP
  6. joshymraj

    joshymraj Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi,

    Your code should work if there is no problem with the 'tval'.Can you just print tval or the whole query "select * from items where model like '"&tval&"' ".Even though we don't use wildcard character '%' with like,it should return a value for an exact match of tval.

    Regards,

    Joshy M Raj
     
    joshymraj, Jul 18, 2007 IP
  7. decodethis

    decodethis Well-Known Member

    Messages:
    436
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    128
    #7
    Yeah, add the "%" wildcard or otherwise the query will only match tval exactly. Depending on what you're looking for you might want to add it in front and behind...
     
    decodethis, Jul 18, 2007 IP