Solved

checking database

Posted on 2004-04-09
3
265 Views
Last Modified: 2007-12-19
Hey guys

ok i am trying to check a value entered by the user if it exists in the access database or not can you please tell me what is wrong with this code. Because when the user clicks sumit it does nothing.
i mean if it finds a match it should redirect the page to "service.asp" otherwise if it does not find the match it should display a error message.

thanks



dim conn, rs, sql
dim client_phone_number

set conn=Server.CreateObject("ADODB.Connection")
conn.open "int213db"

sql = "select * FROM abcTel where client_phone_number='" &request.form("number")&"'"

set rs=server.createobject("ADODB.Recordset")
rs.open sql,conn,adopenstatic



      if rs.recordcount=0 then
            response.write "there are no matches found"
      else
            response.redirect "service.asp"
end if



rs.close
set rs = nothing
conn.close
set conn = nothing
0
Comment
Question by:punjabijatt
3 Comments
 
LVL 12

Expert Comment

by:venkateshwarr
Comment Utility
Enable internet explorer friendly errors and see if it is giving out any errors.
0
 
LVL 1

Accepted Solution

by:
rminnich earned 110 total points
Comment Utility
First, does adopenstatic have a value?  I had to include the type library for ADO to recognize the constant.
Is this line in your ASP file?
<!- METADATA TYPE="TypeLib" FILE="C:\Program Files\Common Files\system\ado\msado15.dll" -->
0
 

Author Comment

by:punjabijatt
Comment Utility
yes it has the include file. here is the code.  










<html>
            <title>
                  Assignment 1
                        </title>
      <body bgcolor=#000066 textcolor="white">

            <h2><font color="blue">Int213 Assignment 2
            <h2><font color="blue">Group Member 1: Gaurav Sood</font></h2>
            <h2><font color="blue">Group Member 2: Samir Budhdeo</font></h2>
            <h2><font color="blue">Student# 035-774-033</font></h2>
            <h2><font color="blue">Email Address: gsood1@learn.senecac.on.ca</font></h2>
            <h2><font color="blue">Instructor: Ling Zhu</font></h2><br>

            <form action="login.asp" method="post" action="">

                  Account# <input type="text" name="number" size=12><font color="red" SIZE="-1"> Format: xxx-xxxxxxx</FONT><BR>
                  Pin#<input type="password" name="pin" size=12><br><br>
                  <INPUT TYPE="submit" NAME="submit" VALUE="Login">

            </form>

<%
            acc = request.form("number")
            pass = request.form("pin")


            
      
            

            If request.form("submit")="Login" then
                  if len(acc)= 0 or len(pass) = 0 then
                        response.write "Error 1 : Please enter a valid user name or password."
                  elseif pass <> "99" then
                        response.write "Error 2 : Password does not match."      
                  elseif len(acc) <> 11 then            
                        response.write "Erro 3 : The length should be 11."
                  elseif mid(acc,4,1) <> "-" then
                        response.write "Error 4 : The character on the forth position must be a (-)"
                  else
                  
      
                  
                  

dim conn, rs, sql
dim client_phone_number

set conn=Server.CreateObject("ADODB.Connection")
conn.open "int213db"

sql = "select * FROM abcTel where client_phone_number='" & acc &"'"

set rs=server.createobject("ADODB.Recordset")
rs.open sql,conn,adopenstatic



      if rs.recordcount=0 then
            response.write "there are no matches found"
      else
            response.redirect "service.asp"
end if



rs.close
set rs = nothing
conn.close
set conn = nothing

end if
end if




%>
</body>
</html>



0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to dynamically set the form action using jQuery.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now