Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2004, 04:04 AM
Authorized User
 
Join Date: Feb 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help PLZ..Condition for Search Page

Hi...I need help Please.....thank's in advance for your help....

I have been trying to do this coding but it's doesn't work...

I'm working on a simple search page that is supposed to search data when user type a Employee ID in the textBox
(Form SearchUpdate.asp)then the datas will show in the next form (ResultUpdate.asp).
Eventhough the user input EmployeeID doesn't exists it will go to the next page(ResultUpdate.asp) but it will show a message "No Data was Found" I don't know why my Response.Write "No Data was found" doesn't work? could someone help me.
heres my code:

ResultUpdate.asp

<%
intID = Request.Form ("EmpID")

    Set Conn = Server.CreateObject ("ADODB.CONNECTION")
    Set rsData = Server.CreateObject ("ADODB.Recordset")
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\TblEmploy.mdb"

 rsData.Open "Select count (*) As Ccount From Data Where EmployeeID =" & intID & "", Conn
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY bgcolor="lightblue">
<CENTER><H1>Update Employee Data</H1></CENTER><BR>
<%
 If rsData("Ccount") <= 0 then
    Response.Write "Data was Not Found" (this part doesn't work)
    'Response.Redirect ("SearchUpdate.asp")
 end if
  If rsData("Ccount") >= 1 then
  Response.Write "Data was Found"
      strsql = "Select * From Data Where EmployeeID =" & intID & ""
        if rsData.State then
       rsData.Close
    end if
        rsData.Open strsql, Conn
        rsData.MoveFirst
 End if

%>
<FORM ACTION= "ConfirmUpdate.asp" METHOD=post Name=frmConfirm >
<CENTER>
<% do while not rsData.EOF %>
<TABLE style="WIDTH: 402px; HEIGHT: 172px" cellSpacing=1 cellPadding=1 width=402 border=1>
  <TR><TD bgcolor=linen><P>EmployeeID</P></TD>
    <TD bgcolor=linen><INPUT type="text" name="EmpID"
    value="<%=rsData("EmployeeID")%>" ></TD></TR>
   <TR><TD bgcolor=linen><P>EmployeeName</P></TD>
    <TD bgcolor=linen><INPUT type="text" name="EmpName"
    value="<%=rsData("EmployeeName")%>" ></TD></TR>
  <TR><TD bgcolor=linen>EmployeeAddress</TD>
    <TD bgcolor=linen><INPUT type="text" name="EmpAddress" value="<%=rsData("EmployeeAddress")%>" ></TD></TR>
  <TR><TD bgcolor=linen>EmployeePhoneHome</TD>
    <TD bgcolor=linen><INPUT type="text" name="EmpPhone" value="<%=rsData("EmployeePhoneHome")%>" ></TD></TR>
  <TR><TD bgcolor=linen>EmployeePostalCode</TD>
    <TD bgcolor=linen><INPUT type="text" name="EmpPostal" value="<%=rsData("EmployeePostalCode")%>" ></TD></TR>
  <TR><TD bgcolor=linen>EmployeeSalary</TD>
    <TD bgcolor=linen><INPUT type="text" name="EmpSalary" value="<%=rsData("EmployeeSalary")%>" ></TD></TR>
<%
rsData.MoveNext
Loop
set rsData= Nothing
%>
</TABLE></P>


I add some code but I'm not sure how to write this code and do I need to add this code or not.

<TR><TD bgcolor=linen><P>EmployeeID</P></TD>
    <TD bgcolor=linen><INPUT type="text" name="EmpID"
    value="<%=If strCounts <= 0 then "Data wasn't Found" Elseif rsData("Ccount") >=1 then rsData("EmployeeID")%>" ></TD></TR>

Any kind of help really appriciate.
thank's

 
Old March 31st, 2004, 10:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Your SQL statement below, I noticed that you are missing a semi-colon(;) between your double quotes.
--------------------------------------------------------------------------------------------
rsData.Open "Select count (*) As Ccount From Data Where EmployeeID =" & intID & "", Conn

--------------------------------------------------------------------------------------------

Do you even get any result when Data is found? If there is no data found, what happens? Do you get an error message?
 
Old April 1st, 2004, 01:03 AM
Authorized User
 
Join Date: Feb 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi jmss66, thank's for your replay....

When the Data are exist all the data show, but when the Data aren't exists I got Error Message:
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.

As for SQL statement it's work with or without semi-colon.

I have been playing around with my code and I make some changes....

<%
rsData.Open "Select * From Data Where EmployeeID =" & intID & "", Conn

If rsData.RecordCount >= 1 then
          Response.Write ("Data Was Found")
          strsql = "Select * From Data Where EmployeeID ='" & intID & "'"
          rsData.Open strsql, Conn
          rsData.MoveFirst

elseIf rsData.RecordCount <= 0 then
   Response.Write "No Data Was Found"
   'Response.Redirect ("SearchUpdate.asp")
end if
%>

 with this code I got different problem...
1. If the Data doesn't exists it still goto the 2nd form
but there is no table only buttons and title are shown.

2. If the Data are exists the data Will show in 2nd form(ResultUpdate.asp),
but the Response.Write ("No Data was Found") still show.

Did I make any sense? I hope I didn't confuse you.

thank's

 
Old April 2nd, 2004, 11:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Hi shopgirl,

Try this code and let me know what happens then we'll go from there. Don't make the If else statement complicated.

<%


rsData.Open "Select * From Data Where EmployeeID =" & intID & "", Conn

If Not rsData.EOF then
Response.Write ("Data Was Found")
strsql = "Select * From Data Where EmployeeID ='" & intID & "'"
rsData.Open strsql, Conn
else
Response.Write "No Data Was Found"
Response.Redirect ("SearchUpdate.asp")
end if
%>


Good luck
 
Old April 5th, 2004, 10:59 PM
Authorized User
 
Join Date: Feb 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jmss66...Thank's for your Replay...

I Used some of your code and did some adjustment in my code, and know my coding is working.

Thank's for your help I appreciated.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Search Condition tmadhavi SQL Server 2000 2 February 21st, 2008 03:13 AM
NEWBIE Question: Expected "" in search condition aasiddle SQL Language 5 March 19th, 2007 03:49 PM
NEWBIE Question: Expected "" in search condition aasiddle ASP.NET 2.0 Basics 0 March 4th, 2007 11:21 AM
ColdFusion MX 7 Login page code--Plz help colorfeifei Dreamweaver (all versions) 0 February 23rd, 2005 11:51 PM
WHERE BETWEEN search condition in sproc jtyson SQL Server 2000 1 August 7th, 2003 09:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.