Subject: " Error" Page not found
Posted By: shoakat Post Date: 11/14/2004 7:29:57 PM
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,address,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><Font Face="Arial" size="1"><%=oRecordset.Fields("au_id")%></Font></TD>
    <TD><Font Face="Arial" size="1"><%=oRecordset.Fields("au_lname")%></Font></TD>
    <TD><Font Face="Arial" size="1"><%=oRecordset.Fields("au_fname")%></Font></TD>
    <TD><Font Face="Arial" size="1"><%=oRecordset.Fields("phone")%></Font></TD>
    <TD><Font Face="Arial" size="1"><%=oRecordset.Fields("address")%></Font></TD>
    <TD><Font Face="Arial" size="1"><%=oRecordset.Fields("city")%></Font></TD>
    <TD><Font Face="Arial" size="1"><%=oRecordset.Fields("state")%></Font></TD>
    <TD><Font Face="Arial" size="1"><%=oRecordset.Fields("zip")%></Font></TD>
    <TD><Font Face="Arial" size="1"><%=oRecordset.Fields("contract")%></Font></TD>    
    </TR>
    <%oRecordset.MoveNext
Loop    
    
%>
</FONT>
</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>
 
 
 
 
 




Reply By: happygv Reply Date: 11/15/2004 2:59:56 AM
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

Go to topic 22129

Return to index page 716
Return to index page 715
Return to index page 714
Return to index page 713
Return to index page 712
Return to index page 711
Return to index page 710
Return to index page 709
Return to index page 708
Return to index page 707