sql statement - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

sql statement

hi,I can't run this sql statement in asp page.
<%
Dim hesap
.........
.........
hesap="'*"+(Request.form("ad"))+"*'"

sql="select * from kutuphane where ISMI Like "+ hesap
'kutuphane is table name and ISMI is a field

rs=Conn.execute(sql)
.................
...............
%>
it works but gives nothing on pages.
So I can't run any LIKE statement in asp pages.
Any help will be greataly appreciated.Best regards.



Comments

  • zeeshanzeeshan Posts: 22Member
    [b][red]This message was edited by the zeeshan at 2002-6-7 7:6:37[/red][/b][hr]
    : hi,I can't run this sql statement in asp page.
    : <%
    : Dim hesap
    : .........
    : .........
    : hesap="'*"+(Request.form("ad"))+"*'"
    :
    : sql="select * from kutuphane where ISMI Like "+ hesap
    : 'kutuphane is table name and ISMI is a field
    :
    : rs=Conn.execute(sql)
    : .................
    : ...............
    : %>
    : it works but gives nothing on pages.
    : So I can't run any LIKE statement in asp pages.
    : Any help will be greataly appreciated.Best regards.
    :


    Hi!!

    There are 2 Solutions for this that you are trying for...


    Solution No 1:

    You write:
    hesap="'*"+(Request.form("ad"))+"*'"

    It must be like this:
    heasp = "'%" & Request.Form("ad") & "%'"
    -----
    For SQL line you wrote:
    heasp = "'%" & Request.Form("ad") & "%'"
    sql="select * from kutuphane where ISMI Like "+ hesap

    that's fine...

    OR it could also be

    sql="select * from kutuphane where ISMI Like " & hesap
    ============================================

    Solution No 2

    You write:
    hesap="'*"+(Request.form("ad"))+"*'"

    It must be like this:
    heasp = Request.Form("ad")

    -----
    For SQL line you wrote:

    sql="select * from kutuphane where ISMI Like "+ hesap

    It must be like

    sql="select * from kutuphane where ISMI Like '%" & hesap & "%'
    ------------------------------------



    SOLUTION 1 :

    heasp = "'%" & Request.Form("ad") & "%'"

    sql="select * from kutuphane where ISMI Like "& hesap


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

    SOLUTION 2 :
    heasp = Request.Form("ad")

    sql="select * from kutuphane where ISMI Like '%" & hesap & "%'


    =================================================================

    And What You're Mistaking is Sterik ( * ) rather percent ( % ) sign


    You Wrote: hesap="'*"+(Request.form("ad"))+"*'"

    Correct Is: hesap="'%"+(Request.form("ad"))+"%'"


    Best Regards :)


    [blue][b]Zeeshan Arshad[/b][/blue]
    [red]Web Developer[/red]
    [green]http://zeeshan.smashglobal.com/[green]



  • mrozermrozer Posts: 4Member
    Thanks for your help on matter programmersheaven.com.Despite of the fact that this message is postted very late.
  • Davide VecchiDavide Vecchi Posts: 17Member
    Try
    [code][italic][b]SET[/b][/italic] rs=Conn.execute(sql)[/code]




    : hi,I can't run this sql statement in asp page.
    : <%
    : Dim hesap
    : .........
    : .........
    : hesap="'*"+(Request.form("ad"))+"*'"
    :
    : sql="select * from kutuphane where ISMI Like "+ hesap
    : 'kutuphane is table name and ISMI is a field
    :
    : [b][italic]rs=Conn.execute(sql)[/italic][/b]
    : .................
    : ...............
    : %>
    : it works but gives nothing on pages.
    : So I can't run any LIKE statement in asp pages.
    : Any help will be greataly appreciated.Best regards.
    :
    :
    :
    :

Sign In or Register to comment.