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 November 14th, 2004, 08:29 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Default " Error" Page not found

function handleSave(){
 document.frmMain.submit();
 }
When I try to hit save button. It gives me an error, page not found.
I am wondering what is this error. Actually I am trying to insert new values to the fields in the database. Can you see my code and see what is the problem.
'ASP Header
Option Explicit
Response.Buffer=true
Response.Expires=-1

Dim oConn 'objConnection to connect to the database
Dim oRecordset 'objRecordset
Dim oCommand 'objCommand used for store procedure and sql

' Database connection string
Const sDatabaseConnectionString = "DATABASE=PUBS;DSN=shoakatdb;UID=shoakat;Password= password"


Dim mode

mode=Request.Form("hdnMode")
If mode= "" Then ' default value is blank
 mode = "Select"
End if

Select Case mode
 Case "Select"
       Call FetchAuthors()
Case "Delete"
     Call FetchAuthors()
     Call DeleteAuthor()
Case "Insert"
   Call FetchAuthors()
   Call InsertAuthor()
Case "Update"
  Call FetchAuthors()
  Call UpdateAuthor()
End Select

Sub FetchAuthors()
'Database Connection String
On Error Resume Next
Set oConn=Server.CreateObject("ADODB.Connection")
oConn.ConnectionString=sDataBaseConnectionString
oConn.Open 'Connect to the database
   If Err.number <> 0 Then
        Response.Write("Problem establishing Database connection")
        Response.End
    End If

Set oCommand = Server.CreateObject("ADODB.Command")
oCommand.ActiveConnection=oConn
oCommand.CommandType=1
oCommand.CommandText="Select * from authors"
Set oRecordset= oCommand.Execute
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
 'INSERT Authors
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''
Sub InsertAuthor()
Dim id
Dim fname
Dim lname
Dim phone
Dim address
Dim city
Dim state
Dim zip
Dim contract

 lname =Request.Form("txtLName")
 fname =Request.Form("txtFName")
 address =Request.Form("txtAddress")
 phone =Request.Form("txtPhone")
 oRecordset.Fields("au_lname")=lname
 oRecordset.Fields("au_fname")=fname
 oRecordset.Fields("phone")=phone
 oRecordset.Fields("address")=address
 On Error Resume Next
Set oConn=Server.CreateObject("ADODB.Connection")
oConn.ConnectionString=sDataBaseConnectionString
oConn.Open 'Connect to the database
   If Err.number <> 0 Then
        Response.Write("Problem establishing Database connection")
        Response.End
    End If

Set oCommand = Server.CreateObject("ADODB.Command")
oCommand.ActiveConnection=oConn
oCommand.CommandType=1
oCommand.CommandText="BuildInsertSQL(lname,fname,a ddress,phone)"
 oCommand.Execute
 oConn.Close ' Close the database connection and release memory
Set oConn = Nothing
Set oCommand = Nothing
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''
' BuildInsertSQL - Creates the Insert SQL statement
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''
Function BuildInsertSQL(lname,fname,address,phone)
Dim sql
sql= "Insert into Authors Values('" &lname& "','"&fname&" ','" &address&" ',' "&phone& "')"
BuildInsertSQL =sql
End Function


%>

<html>
<Head>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<Script language="JavaScript">
/* *************************************
 HandleNew Handles the new Button Click
 ****************************** */
 function HandleNew(){
var entryFieldsHTML= "<Table align='center' width='250px'>" +
 "<TR><TD><B>LastName</B></TD><TD><Input type='text' name='txtLName' ></TD></TR>" +
 "<TR><TD><B>FirstName</B></TD><TD><Input type='text' name='txtFName' ></TD></TR>"+
 "<TR><TD><B>address</B></TD><TD><Input type='text' name='txtAddress'></TD></TR>"+
 "<TR><TD><B>Phone</B></TD><TD><Input type='text' name='txtPhone'></TD></TR>"+
 "<TR><TD align='center' colspan='2'><Input type='button' value='Save' id='btnSave' onclick='handleSave();'></TD></TR>"
 "</TABLE>"
 entryFields.innerHTML = entryFieldsHTML;
 return;
 }


 /* **************************************
handleSave Handles the New Button Click
***********************************/

function handleSave(){

    document.frmMain.submit();
 }






</Script>
</Head>
<BODY >
<Table width="800px" border="1" align="center" >


        <TD align="center"><B>ID</B></TD>
        <TD align="center"><B>Last Name</B></TD>
        <TD><B>First Name</B></TD>
        <TD><B>Phone</B></TD>
        <TD><B>Address</B></TD>
        <TD><B>City</B></TD>
        <TD><B>State</B></TD>
        <TD ><B>Zip</B></TD>
        <TD ><B>Contract</B></TD>

<%Do until oRecordset.EOF%>
   <TR>
    <TD><%=oRecordset.Fields("au_id")%></TD>
    <TD><%=oRecordset.Fields("au_lname")%></TD>
    <TD><%=oRecordset.Fields("au_fname")%></TD>
    <TD><%=oRecordset.Fields("phone")%></TD>
    <TD><%=oRecordset.Fields("address")%></TD>
    <TD><%=oRecordset.Fields("city")%></TD>
    <TD><%=oRecordset.Fields("state")%></TD>
    <TD><%=oRecordset.Fields("zip")%></TD>
    <TD><%=oRecordset.Fields("contract")%></TD>
    </TR>
    <%oRecordset.MoveNext
Loop

%>

</Table>

<Form name="frmMain" method="post" action="ADOExample.asp">
    <Input type="hidden" name="hdnMode" value="">
    <DIV id="entryFields"></DIV>
<Center>
    <Input type= "button" name="btnNew" value="New" onClick="HandleNew();">
</Center>
 </Body>









 
Old November 15th, 2004, 03:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

What is the filename where this code exists? And check where does the ADOExample.asp reside?

Is that you submit to the same file where the form is located?

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
The page cannot be found tbroom BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 13 August 18th, 2006 10:32 AM
Page not found upon image upload phpPro2000 Pro PHP 1 April 20th, 2006 02:37 PM
Exception:Page Not found arnabghosh C# 4 December 3rd, 2005 11:43 AM
HTTP 404 Page not found hosefo81 Beginning PHP 4 October 26th, 2003 06:27 PM
Page Not Found Error ztz02 Classic ASP Basics 2 June 25th, 2003 08:52 AM





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