SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 27th, 2003, 04:30 AM
Abd Abd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: NIG
Posts: 4 Abd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Error Message

Hi all,

I have two forms, form1 and form2, form1 receives a phone number POST it to form2 which select from an MS SQL DB and populate form2.

My problem is I want an alert or a meaningfull Error message to be displayed when a user enters a phone number that is not in the Database , below is my piece of code for the form that is getting populate;

<%
category = TRIM( Request.Form( "cat" ) )
username = TRIM( Request.Form( "username" ) )



IF username <> "" THEN
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=ABD;UID=sa;PWD=abd;DATABASE=abdul"
Set RS= Server.CreateObject( "ADODB.Recordset" )

If category = "Globe" then
RS.Open "select * from globe where phonenum = '" &username& "'", Con

firstname = RS.Fields("firstname")
lastname = RS.Fields("lastname")
middlename = RS.Fields("middlename")
homeadd = RS.Fields("homeadd")
busadd = RS.Fields("busadd")
terrifplan = RS.Fields("terrifplan")
state = RS.Fields("state")
phonenum = RS.Fields("phonenum")
typeofpay = RS.Fields("typeofpay")
assignedto = RS.Fields("assignedto")
nservicereq = RS.Fields("nservicereq")
//Comment = RS.Fields("Comment")


End if
Con.Close
Set RS = Nothing
Set Con = Nothing
END IF
%>


Thanks

Abd

Reply With Quote
  #2  
Old March 27th, 2003, 08:26 AM
mtndew mtndew is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 mtndew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You need to ask, after your "RS.Open" if at EOF and if so do a Response.write message.

Here's how I do it to check for existing SSN in a database;

rs.open "Select * From tblStudents Where SSN = " & Request.Form("SSN"), con, adOpenKeyset, adLockOptimistic
If rs.EOF Then
rs.addnew
'code to add new data
Else
response.write("<BR>This SSN Already Exists in the Database. The next page will show the existing record.")
End If

I then open up the page that allows for editing of the data showing the existing record.

Hope this helps.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Error Message


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway