View Single Post
  #1 (permalink)  
Old November 14th, 2004, 08:29 PM
shoakat shoakat is offline
Friend of Wrox
 
Join Date: Jul 2004
Location: , , .
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>









Reply With Quote