|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Error Message |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|