Now that you can build a form and save its results, let’s look at an example
of the whole process. This example will show how to create a form for submitting
a new record to the database.
One thing that you need to decide on is whether to give the Gatsby
Application object session or page scope. If you are letting Gatsby handle
authentication, then you must give the object session scope. Otherwise, it would
lose the credentials on every page and all you would ever see is the login
dialog.Another consideration is performance. Opening and closing the database
each time you view a page may put an unnecessary strain on your server. The
following example will use session scope.
<%@ Language = Jscript %>
<%
// Create the Gatsby Application object
var Gatsby =
Server.CreateObject( "Gatsby.Application.3" );
// explicitly open the data sources file
Gatsby.Open( "C:\\Program Files\\Gatsby\\Database Explorer\\Data Sources.gds", "admin", "" );
%>
<html>
<head>
<style type="text/css">
//
insert the contents of the style
sheet
<%
if ( Gatsby.Styles.cssText != null )
Response.Write(Gatsby.Styles.cssText);
%>
</style>
</head>
<body>
<%
var MyForm = Gatsby.CreateForm( "MyForm", "/Intranet/Staff" );
if ( MyForm.ProcessPost() > 0 )
// Something was processed and it was successful
Response.Write( "Thank you for submitting." );
else
{
Response.Write( "<script>"
+ MyForm.Script + "</script>"
);
Response.Write( MyForm.htmlHeader );
Response.Write( MyForm.htmlBody );
Response.Write( "<input type=submit>" );
Response.Write( MyForm.htmlFooter );
}
Gatsby.Close();
%>
</body>
</html>