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.

db problemo

fasfas Posts: 18Member
im having problem with this code its not redirecting .. the record set's current count is -1 no rows are returning from db...plz a quivk help is required

<%
id=request.form("usr")
sec=request.form("pwd")
'response.write(id)
'response.write(sec)
set con=Server.createobject("Adodb.connection")
set rs=Server.createobject("Adodb.recordset")
con.open "DSN=test;usr=;pwd=;"
sql="select * from user where userid='"&id&"' and pass='"&sec&"'" //////"'this is the query..."\\\
rs.Open sql,con

if (rs.recordcount > 0) then
Session("auth")="allow"
response.redirect("success.asp")
else
response.redirect("error.asp")
end if
%>

Comments

  • FlakesFlakes Posts: 642Member
    : im having problem with this code its not redirecting .. the record set's current count is -1 no rows are returning from db...plz a quivk help is required
    :
    : <%
    : id=request.form("usr")
    : sec=request.form("pwd")
    : 'response.write(id)
    : 'response.write(sec)
    : set con=Server.createobject("Adodb.connection")
    : set rs=Server.createobject("Adodb.recordset")
    : con.open "DSN=test;usr=;pwd=;"
    : sql="select * from user where userid='"&id&"' and pass='"&sec&"'" //////"'this is the query..."\\\
    [red] rs.Open sql,con,2,3[/red]
    :
    : if (rs.recordcount > 0) then
    : Session("auth")="allow"
    : response.redirect("success.asp")
    : else
    : response.redirect("error.asp")
    : end if
    : %>
    :


    Change the rs.open statement as shown.The default cursor type might not be supporting the recordcount.The "2,3" thing is I *think* adOpenDynamic and adLockOptimistic . Can't really remember that thing :-) .
    If that doesn't work ,try setting
    rs.cursorLocation=adUseClient before opening the resordset.
    to use the adUseClient ,you will have to include the file "adovbs.inc".If you look in that file you will also see what 2,3 stands for and what the magic number for adUseClient is.Try it and let us know

  • mhadgutrajarammhadgutrajaram Posts: 8Member

    Hi friend ,

    Always use the given approach for using recodset


    <%
    id=request.form("usr")
    sec=request.form("pwd")
    'response.write(id)
    'response.write(sec)
    set con=Server.createobject("Adodb.connection")
    set rs=Server.createobject("Adodb.recordset")
    con.open "DSN=test;usr=;pwd=;"
    sql="select * from user where userid='"&id&"' and pass = '"&sec&"'" //////"'this is the query..."\\\
    rs.ActiveConnection = con
    rs.LockType = 3 'adLockOptimistic
    rs.CursorLocation = 3 'adUseClient
    rs.CursorType = 2 'adOpenDynamic
    rs.open(sql)

    if (rs.recordcount > 0) then
    Session("auth")="allow"
    response.redirect("success.asp")
    else
    response.redirect("error.asp")
    end if
    %>


    This will surely solve ur problem.

    Regads,

    Rajaram Mhadgut :)

    you can contact me at mhadgutrajaram@hotmail.com


    : im having problem with this code its not redirecting .. the record set's current count is -1 no rows are returning from db...plz a quivk help is required
    :
    : <%
    : id=request.form("usr")
    : sec=request.form("pwd")
    : 'response.write(id)
    : 'response.write(sec)
    : set con=Server.createobject("Adodb.connection")
    : set rs=Server.createobject("Adodb.recordset")
    : con.open "DSN=test;usr=;pwd=;"
    : sql="select * from user where userid='"&id&"' and pass='"&sec&"'" //////"'this is the query..."\\\
    : rs.Open sql,con
    :
    : if (rs.recordcount > 0) then
    : Session("auth")="allow"
    : response.redirect("success.asp")
    : else
    : response.redirect("error.asp")
    : end if
    : %>
    :

Sign In or Register to comment.