Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic 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 November 16th, 2003, 05:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default Exception Problem

I use this query

ssql="select software.rec_id sofid,software.stn_no, software.software,softwarelist.version from software,softwarelist2 where software.software=softwarelist.software and software.stn_no='"& stn_no &"' order by software.software"

if ssql=null then

m=server.URLEncode("Software not found")
Response.Redirect("update_inv_item.asp?msg=" & m)

Else // execute connection

set rs=cn.Execute(ssql)

Response.Write("<input type=hidden name=stn_no value='" & rs("stn_no") & "'>") // line 90

do while rs.eof=false

Some time record no record found by the above query so it give following error message.

Error Type:
(0x80020009)
Exception occurred.
/dcildepts/compsys/inventory/inv_update_response3.asp, line 90


How can handling this exception ? if record not retrieve by the query it should redirect to another page and display message
That “record no found”. If record found then is working properly, problem in record not found.


Mateen
 
Old November 16th, 2003, 11:35 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Any time you execute a query that may return no rows (which is usually all of them) check for the EOF flag....

rs = conn.Execute(sSql)
If Not rs.EOF Then
    'Rows found, do what you need with the rows.
Else
    'No Rows found, handle it.
End If

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 18th, 2003, 01:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your reponse.
it is working.

I have another condition problem.
I have data in the software table like this

stn_no software
--------- ---------
comp1 windows 95
comp1 windows 98
comp1 adobe acrobat
comp2 windows 95
comp2 windows 98
comp2 windows 2000
comp2 windows xp
…………….

coding is
----------
<%
stn_no=Request.Form("stn_no")
software=Request.Form("software")

for x = 1 to Request.Form("software").Count

ssql="select software from software2 where stn_no='"&(stn_no)&"' and software='"& Request.Form("software").Item(x) &"'"

next

set rs=cn.Execute(ssql)

if Not rs.EOF Then

x=server.URLEncode("Software already Installed")
Response.Redirect("inv_update_response3.asp?msg=" & x)

else

for x = 1 to Request.Form("software").Count

    sql = "insert into software2 (software,stn_no) values ("
    sql = sql & "'" & Request.Form("software").Item(x) & "','" & stn_no & "')"

    cn.Execute sql
next

end if
%>

multiple software received from the asp page.

what condition (loop) will apply that if software exit in stn_no it should redirect the page with the message
that "software already installed"

if software not found in stn_no it insert records, but it should not insert duplicate records.

this condition check only single record, when multiple records
received, it does not work, and insert duplicate records, why ?

Mateen


Quote:
quote:Originally posted by planoie
 Any time you execute a query that may return no rows (which is usually all of them) check for the EOF flag....

rs = conn.Execute(sSql)
If Not rs.EOF Then
    'Rows found, do what you need with the rows.
Else
    'No Rows found, handle it.
End If

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
COM Exception muralidharan.d VS.NET 2002/2003 0 August 7th, 2007 02:49 PM
Exception Ochi C# 1 January 15th, 2006 11:38 PM
Problem in bean lookup, no exception avaniamin J2EE 0 November 11th, 2005 05:40 AM
Exception Occured (0x80020009) problem dominic_huang Classic ASP Databases 1 November 17th, 2004 01:13 AM
a problem about the exception? watson C# 3 June 13th, 2004 05:45 PM





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