Very simple question - 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.

Very simple question

Hi, I am new in ASP programming. Can anyone tell me how to exit a condition. e.g.
[code]
<%
dim nameFld, pwFld
nameFld=request.form("nameFld")

pwFld=request.form("pwFld")

if nameFld="" then
response.write("Please enter a user name") &"<br>"

end if

if pwFld="" then
response.write("Please enter a password") &"
"
<1-- I want to exit here-->
end if

%>
...
[/code]

Comments

  • chick80chick80 Posts: 349Member
    You can use else...

    : [code]
    : <%
    : dim nameFld, pwFld
    : nameFld=request.form("nameFld")
    :
    : pwFld=request.form("pwFld")
    :
    : if nameFld="" then
    : response.write("Please enter a user name") &""
    : else if pwFld="" then
    : response.write("Please enter a password") &""
    : end if
    :
    : %>
    : ...
    : [/code]

    nICO

    [hr]
    [italic]How beautiful, if sorrow had not made Sorrow more beautiful than Beauty itself.[/italic]
    JOHN KEATS


  • jzhoujzhou Posts: 78Member
    : You can use else...
    :
    : : [code]
    : : <%
    : : dim nameFld, pwFld
    : : nameFld=request.form("nameFld")
    : :
    : : pwFld=request.form("pwFld")
    : :
    : : if nameFld="" then
    : : response.write("Please enter a user name") &""
    : : else if pwFld="" then
    : : response.write("Please enter a password") &""
    : : end if
    : :
    : : %>
    : : ...
    : : [/code]
    :
    : nICO
    :
    : [hr]
    : [italic]How beautiful, if sorrow had not made Sorrow more beautiful than Beauty itself.[/italic]
    : JOHN KEATS
    :
    :
    :

    Thank you. This problem is solved. But I can't connect to the SQL server. I am not sure where I am wrong?
    [code]
    <%
    dim nameFld, pwFld
    nameFld=request.form("nameFld")

    pwFld=request.form("pwFld")

    if nameFld="" then
    response.write("Please enter a user name") &""

    elseif pwFld="" then
    response.write("Please enter a password") &""

    end if

    %>
    <%
    dim conn, objRds
    set conn = server.createobject("ADODB.Connection")
    set objRds=Server.CreateObject("adodb.recordset")

    conn.Provider ="SQL SERVER"
    conn.ConnectionString = "dsn=Vehicle;uid=sa;Pwd="
    conn.open

    %>
    <%
    strSQL="select * from login where login_name='"&nameFld&"' and login_pw='"&pwFld&"'"
    set ojbRds=conn.Execute(strSQL)

    if objRds.recordcount=0 then
    Response.Write("Wrong login info.")
    end if

    %>
    [/code]

    Error Type:
    ADODB.Recordset (0x800A0BB9)
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
    /vehicleasp/login.asp, line 36




    Judy
Sign In or Register to comment.