Link to home
Start Free TrialLog in
Avatar of enochstek
enochstek

asked on

Getting code error when trying to run .asp page from FrontPage 2002

I am trying to link a access database from Frontpage 2002. I went through the database wizard in Frontpage and it created 2 pages. One was called submission_form.asp and the other is results_page.asp. I created the database to contain three fields. Customer, Unit and History. When run the results_page.asp it comes up with no records. The database started with no records so I went into access and added one to test it. When I ran the results_page.asp after putting the data in the database it still didn't show any records. When I hit Preview in Browser on the submission_form.asp it gave me the following code instead of a page with the fields on it:
<%
' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit.

On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Err.Clear

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
      Err.Clear

      Set fp_conn =  Server.CreateObject("ADODB.Connection")
      FP_DumpError strErrorUrl, "Cannot create connection"

      Set fp_rs = Server.CreateObject("ADODB.Recordset")
      FP_DumpError strErrorUrl, "Cannot create record set"

      fp_conn.Open Application("production_ConnectionString")
      FP_DumpError strErrorUrl, "Cannot open database"

      fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
      FP_DumpError strErrorUrl, "Cannot open record set"

      fp_rs.AddNew
      FP_DumpError strErrorUrl, "Cannot add new record set to the database"
      Dim arFormFields0(3)
      Dim arFormDBFields0(3)
      Dim arFormValues0(3)

      arFormFields0(0) = "Company"
      arFormDBFields0(0) = "Company"
      arFormValues0(0) = Request("Company")
      arFormFields0(1) = "Unit"
      arFormDBFields0(1) = "Unit"
      arFormValues0(1) = Request("Unit")
      arFormFields0(2) = "History"
      arFormDBFields0(2) = "History"
      arFormValues0(2) = Request("History")

      FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0


      fp_rs.Update
      FP_DumpError strErrorUrl, "Cannot update the database"

      fp_rs.Close
      fp_conn.Close

      FP_FormConfirmationFromArrays "text/html; charset=windows-1252",_
                                    "Form Confirmation",_
                                    "Thank you for submitting the following information:",_
                                    "submission_form.asp",_
                                    "Return to the form.",_
                                    arFormDBFields0,_
                                    arFormValues0

End If
End If

Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")

%>
<% Response.Buffer = True %>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Results -- New</title>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFFF">

<table width="100%" align=left>
  <tr>
    <td width="50%">
        <b><font size=+3 color="#000080"> Submission Form </font></b>
      </td>
    <td width="50%" align=right>
      <table>
        <tr>
          <td>
            <a href="results_page.asp" target="_top">Results Page</a> |
Submission Form

          </td>
        </tr>
      </table>
      </td>
  </tr>
</table>


<p>
<br clear="all">
<hr>
<p>

<!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --><script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form1_Validator(theForm)
{

  if (theForm.Company.value.length > 255)
  {
    alert("Please enter at most 255 characters in the \"Company\" field.");
    theForm.Company.focus();
    return (false);
  }

  if (theForm.Unit.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Unit\" field.");
    theForm.Unit.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.Unit.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Unit\" field.");
    theForm.Unit.focus();
    return (false);
  }

  if (theForm.History.value.length > 255)
  {
    alert("Please enter at most 255 characters in the \"History\" field.");
    theForm.History.focus();
    return (false);
  }
  return (true);
}
//--></script><!--webbot BOT="GeneratedScript" endspan --><form METHOD="POST" action="submission_form.asp" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1" webbot-action="--WEBBOT-SELF--">

<!--webbot bot="SaveDatabase" suggestedext="asp" s-dataconnection="production" s-recordsource="Results" s-form-fields="Company Unit History" s-form-dbfields="Company Unit History " b-usedbfieldsforconfirmation="True" u-asp-include-url="../../_fpclass/fpdbform.inc" startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="../../_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" endspan i-checksum="43152" -->

<p><b>Company</b><br>
&nbsp;<!--webbot bot="Validation" s-display-name="Company" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input type="TEXT" name="Company" size="64" value="" maxlength="255"><br>
</p>
<p><b>Unit</b><br>
&nbsp;<!--webbot bot="Validation" s-display-name="Unit" s-data-type="Integer" b-value-required="False" i-maximum-length="5" --><textarea rows="10" name="Unit" cols="5"></textarea><br>
</p>
<p><b>History</b><br>
&nbsp;<!--webbot bot="Validation" s-display-name="History" s-data-type="String" b-value-required="False" i-maximum-length="255" --><input type="TEXT" name="History" size="64" value="" maxlength="255"><br>
</p>


<p><input type="submit" value="    OK    "><input type="reset" value=" Reset "></p>

</form>

</body>

</html>



Can anyone help me with this and tell me what I could be doing wrong. I am running XP pro and ran it from myweb in My Documents. I also tried moving it to a server we have setup on the network. I put it to \\server\inetpub\wwwroot\production. The server is running Windows 2000 Server and I set up and ODBC account linking to the database in the production folder. I really need some help getting this running. If anyone knows an easier way to do this I will be open to suggestions. Ive read the asp wizard stuff on Microsoft.com and numberous files on asp and they all go through the same steps that end up with the same results.
Thanks,
Josh Enochs
Avatar of seanpowell
seanpowell
Flag of Canada image

>>I am running XP pro and ran it from myweb in My Documents.
When you're using ASP, you need to run it through IIS - which needs to be installed on your PC. (Let me know if it isn't)

So - the site needs to be either in C:/inetpub/wwwroot/submission_form.asp. or in a subweb C:/inetpub/wwwroot/myweb/submission_form.asp

Then, you open the site in the browser using this:

http://localhost/submission_form.asp - or in the second case, http://localhost/myweb/submission_form.asp

You can't run the asp pages using C://My Documents/myweb, because the code needs to use the asp engine in IIS.

Let me know...

Thanks,
Sean
Avatar of enochstek
enochstek

ASKER

I also tried running it off the server which has IIS installed and it did the same thing.
Josh Enochs
>>The server is running Windows 2000 Server and I set up and ODBC account linking to the database in the production folder.

The code above states:
fp_conn.Open Application("production_ConnectionString")

which FrontPage normally defines in the global.asa file in the root of the site. If you have created a new connection to the db, then you need to make sure your code recognizes it.

When you open the live site on the server, and go to Tools > Web Settings > Database, what happens when you verify the connection?
Ok, When I open frontpage on my XP Pro machine and then go to File - Open and point it to the Web5 that is on the Server in inetpub\wwwroot\production and verify the connection it verifies it and puts a green checkmark next to it.
Ok Seanpowell,
I got home and put the Myweb (which contained the forms and my database) folder into \inetpub\wwwroot and changed my database path to use that database and I verified it. It checked ok and was verified. I then went to http:\\localhost\index.htm and it brought up my index page. i then clicked on the submissions form link and it brought up the submission form and not asp code which is right but then when I typed in data in the three fields and hit submit it said thank you for submitting like it had worked, but then when I go to the database, the data that I entered isn't there?!?!? Any idea why it didn't update it?
Thanks,
Josh Enochs
ASKER CERTIFIED SOLUTION
Avatar of seanpowell
seanpowell
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sean,
I looked at the link you sent me and I have been through that a few times already. I think I have got a problem with asp or something. When I publish my webpage to the server it says that asp is not supported on the server I am publishing to so the three pages will not work properly. But I am running Server 2000 with IIS 5.0. Do you know what would cause this?
Sean,
I got it to update the database now. It was because the frontpage extensions were #@!#@ up. I reinstalled it on the server and it worked. Now I am getting another problem though. When I go to the Form Properties on my Submission.asp page to change what field the text box is linked to I click on Options to go in and change it and where it says what database connection to use it has my database name and it says connecting to database and then gives me this error:

Server error: Unable to retrieve the list of record sources from a database using the connection string:

DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=fpdb/production.mdb.

The following error message comes from the database driver software; it may appear in a different language depending on how the driver is configured.
-------------------------------------------------------


Source: ADO
Number: -2146824584 (0x800a0e78)
Do you know what this is?
Were you using a username and passowrd for the db?
Nevermind! I feel so stupid! It was because I was in the database on another pc. Thanks for your help!
Hey - you wouldn't believe some of the things I've done. I can't even mention them here...

I'm so happy you're back on track :-)