Solved

checking database

Posted on 2004-04-09
3
266 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
ID: 10795929
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
ID: 10795949
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
ID: 10796633
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 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

18 Experts available now in Live!

Get 1:1 Help Now