Howdy, Stranger!

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

Categories

sql statement

mrozermrozer Member Posts: 4
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 Member Posts: 22
    [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 Member Posts: 4
    Thanks for your help on matter programmersheaven.com.Despite of the fact that this message is postted very late.
  • Davide VecchiDavide Vecchi Member Posts: 17
    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.