Click to return to the Essentials home page    
Web Workshop  |  Essentials

by Rafael M. Muñoz & Tom Moran

Forms and Functions


Rafael M. Muñoz
Tom Moran
Microsoft Corporation

June 7, 1999

The following article was originally published in the MSDN Online Voices "Web Men Talking" column.

Contents
You actually wrote Haiku! - Results from our Computerku contest
Take two aspirins - Split Distribution Units
The Post-man Cometh - Posting data from a form to an Access database
Up front and personal - Displaying a modal dialog with Internet Explorer
The Web Men in Short

You actually wrote Haiku!

We received far more entries than we had expected for our little Haiku contest. Evidently, nearly everyone thought they could do better than we did. And you weren't too far off the mark. Here are our four favorites:

Sweet Mother of God
You want me to write Haiku?
Get a %!@##ing life!

Submitted by Dave Moyses
People like Web sites
That have nice flashy graphics
But not me, too slow

Submitted by Chris Williams
My ActiveX doc
Displaying in the browser.
Finally, it WORKS

Submitted by Dwayne Macadangdang
"Make it cross-browser."
"The deadline is yesterday."
Oh death, where is thy sting?

Submitted by Jonathon Brownell

TopBack to top

Take two aspirins

Dear Web Men:

I'm desperately looking for information on split cab files. I've read the documentation that comes with the Java SDK, but it doesn't cover how to reference the split cabs in an HTML page. After running Dubuild on V1.cab, you end up with V2.cab and ~V2.cab. How are these referenced? Which of these is downloaded to the browser, and how does this mechanism work?

Could you help in any way?

Feargal Costello

The Web Men reply:

Feargal, your question is one of the most common questions put to the Microsoft Java Support team. We can tell you they have a "splitting" headache that two aspirins just won't cure.

A CAB, or Cabinet, is a very popular method of distributing Java classes via the Internet. Refer to Introduction to Cabinets -- A New Way to Distribute Java Classes for more information. CABs also reduce download times over the Internet, which folks always appreciate. Refer to Reducing Download Times with Cabinet Files.

A split distribution unit, or split DU, is another way to distribute updated versions of software. Split DUs also speed up the download time, and are built using the command line tool to which you refer: Dubuild Non-MSDN Online link. When creating a split DU, we take the original CAB -- for instance, mycab1.cab -- and create a new mycab2.cab, which contains any new or changed files, and a ~mycab2.cab, which contains the original, unchanged files.

Internet Explorer performs the magic of downloading and installing the split DU by examining the name and value attributes of the PARAM element. There are three PARAM values used with split DUs (their values will need to correspond to your CAB):

<PARAM NAME=useslibrary VALUE="Web Men">

<PARAM NAME=useslibrarycodebase VALUE="mycab2.cab">

<PARAM NAME=useslibraryversion VALUE="1,1,23,0">

Useslibrary refers to the friendly name of our CAB and is one of the input options to Dubuild. Useslibrarycodebase references the new CAB we want to install, and can be either a file or a URL reference. Useslibraryversion is the version number of our CAB, which is used to update the user's machine.

The magic goes something like this: Internet Explorer Non-MSDN Online link encounters a CAB file, and checks to see whether the friendly name is already registered on the machine and that the versions match. If it does exist and the versions match, nothing is downloaded, and the software is run from the client's machine. If an older version exists, mycab2.cab alone downloads, installs, and updates the version number. If the code doesn't exist, both mycab2.cab and ~mycab2.cab are downloaded and installed, so that the complete package is then contained on the client's machine.

Caution: When creating a CAB file, you need to digitally sign it so that you can install your code to a user's machine. Refer to Digitally Signing a Cabinet File Non-MSDN Online link. Many users don't realize that when playing with split DUs you must sign both the new CAB, mycab2.cab, and the second CAB, ~mycab2.cab. If you forget, your CAB will not download correctly.

Here are some other great Microsoft Knowledge Base articles or reference for building and working with CAB files:

Q168941, INFO: Frequently Asked Questions for CAB Files Non-MSDN Online link

Q193877, HOWTO: Make Your Java Code Trusted in Internet Explorer Non-MSDN Online link

Microsoft SDK for Java 3.2 Documentation

TopBack to top

The Post-man Cometh

Dear Web Men:

I've been searching for technical articles but cannot find the answer to the problem of posting data to update an Access database from an Active Server Pages file. (I've been able to view the database but would also like to update it from a Web page.)

Thanks in advance,

David Venter

What is a connection string to a Data Source in VBScript for Microsoft Access? My point is that I don't want to call up the administrator every time I want to define a system OBDC connection on the Web server.

Jorge Ituarte

The Web Men reply:

Since we ended up with quite a few questions of this type, we'll answer both of the queries above in one fell swoop. This is a fairly simple task, once you understand the basic theory. We'll create a form that collects information, submits it to another Active Server Pages (ASP) file, connects via a DSN-less connection to an Access database, and then inserts that information into the database.

Your first step is to create an Access database with the following fieldnames and values:

CustEMail, Text, 50

Technology, Text, 50

Question, Text, Memo

Next, you'll want to create a new project in Visual InterDev™. Create an .asp file, and call it "Page1.asp". Your first .asp file will consist of the following:


<BODY>

<Form action = "WebMen.asp" method="post">
<B><BR>Questions for Dr Gui</B><P>
<BR>Customer e-mail<BR><Input NAME="CustEMail" size ="20"><BR>
<BR><BR>Technology Area<BR>

<SELECT ID="technology" NAME="technology"><BR>
<OPTION SELECTED VALUE="ADO">ADO</OPTION><BR>
<OPTION value="Win32">Win32</OPTION><BR>
<OPTION value="ATL">ATL</OPTION><BR>
<OPTION value="ASP">Active Server Pages</OPTION><BR>
<OPTION value="MFC">MFC</OPTION><BR>
<OPTION value="ADO">ADO</OPTION><BR>
</SELECT><BR>

<BR><BR>Question 
<P><TEXTAREA ROWS=8 COLS=50 ID="Question" NAME="Question" >Type your question here</TEXTAREA>
<BR><BR><Input type="submit" value="Add to Access database">
<BR><hr></form><BR>
</BODY> 

We want our front page to take advantage of ASP features, but it isn't necessary that the form be in ASP format. In fact, if you're using an Access database, you may not require high-performance in-demand features -- and you can get increased performance by using standard HTML.

The intention of this little sample is to allow you to get together with all of your friends, save all of your questions in a common Access database, and then fire off that database to our good friend Dr. GUI. You have a text box for entering an e-mail address, a listbox from which you can select your favorite technology, and a text area to describe your question.

You'll notice that the method for the form action is "post." Using "get" limits the number of characters, and therefore wouldn't be a good choice for a form that uses free-form text. For more information on programming with forms, go to webreference.com Non-MS link. Next, create a second .asp file, and title this one "webmen.asp" (since that is what is listed in the previous file's form action). Add the following code:

<%
'Create DSNLess connection
set oConn=server.createobject("adodb.connection")
oConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\projectx\wmq.mdb;Persist Security Info=False"
oConn.Open

'Build Insert statement
SQLStatement = "INSERT INTO Questions (CustEMail, Technology, Question)" 
SQLStatement = SQLStatement & "VALUES ('" & Request.Form("CustEMail") & "'"
SQLStatement = SQLStatement & ",'" & Request.Form("Technology") & "'"
SQLStatement = SQLStatement & ",'" & Request.Form("Question") &"')"

'Execute
oConn.execute SQLStatement

'Show what the statement looked like
Response.Write "The following SQL Statement was executed: <BR><BR>"
Response.Write SQLStatement & "<BR>"
   
'Close up shop
oConn.Close
set oConn=nothing

%>

The first thing we do on this page is create a DSN-less connection to our Access database. (If you have questions about how to do this, check out KB Article Q167294Using a File DSN or DSN-less Connection with ASP Files Non-MSDN Online link, and Working with Database Projects Non-MSDN Online link). Next, we build a statement to insert the values we collected from our form into the database. Watch those single and double quotes. Remember that a SQL statement uses single quotes for text. We then write out the SQL statement so you can see what it looks like. Finally, we do the necessary cleanup. For troubleshooting purposes, we recommend that you start your page with only the connection information and don't try to do anything else. Once you can connect to the database without getting the dreaded 80004005 error, then move on to add the other stuff. If you have problems, check that the path to your Access database is valid and that your I_USR account has permission both to the file itself and to the folder in which that file resides.

You'll notice that we included no error checking here, primarily due to length. You could, and should, add error checking to your code (it's fairly easy to do). Some good tips are in Q168336 Howto: Three Ways to Open ADO Connection and Recordset Objects Non-MSDN Online link. You can also find more information by simply searching MSDN for "ado error."

Finally, consider using SQL Server for your solution. Access is great, and can be a perfect fit for your needs, but if you anticipate ever having high volumes in the future, you'll want to look at SQL Server. See Q222135 ACC97: Using Microsoft Jet with IIS Non-MSDN Online link for more details.

TopBack to top

Up front and personal

Dear Web Men:

I am working on an application that sometimes requires users to do data entry in child windows. I want those child windows to maintain focus until data entry is complete. I have attempted to utilize the window.focus event in the parent window to recognize focus and reset it to the child window. However, the parent window does not recognize the focus event.

Thanks for any help.

Mark L. Gerszewski

The Web Men reply:

So you want to display a window up front and personal?

We are going to assume you want to create a window that is brought up on command, keeps focus, and then is removed when the user is done -- returning focus back to the parent window. The key here is that the new window is removed before turning the focus back to the parent window. This process is referred to as a modal dialog.

Dynamic HTML (DHTML) allows you to use the window object and its showModalDialog method to create just such a dialog. The showModialDialog method takes a regular HTML page as one of its parameters and creates the desired dialog window. Through the window object's dialogArguments and returnValue properties, the parent window and dialog can pass information back and forth. You can also use the focus method to set focus to a particular control in your dialog, thereby assisting the user.

For a basic sample, see the documentation on the showModalDialog method. For more in-depth examples, read "Working with Windows, Frames, and Dialog Boxes".

TopBack to top

The Web Men in Short

Q. Norbert Ordog wants to use ASP technology to detect whether a client's browser supports Java applets.

A. This type of browser support can be tested with either a server- or client-side solution. Refer to Client Capabilities for more information and samples.

Q. Ragavan Vaidyanathan asks how to set up a Web server and what DNS is.

A. Contact your ISP -- usually a great resource for this process. If you want to do it all yourself, be prepared for heavy investment in both dollars and study time. The best place to start is Getting Started with Microsoft DNS Server Non-MSDN Online link.

Q. Steve Medcalf wants to find the Internet Explorer Administration Kit.

A. The latest information can be found on the Microsoft Windows Technologies, Internet Explorer Administration Kit Non-MSDN Online link site.

Q. Bryant Likes wants to know why we didn't point out the really easy way of stopping someone from printing out information from a Web page.

A. Thanks, Bryant, for sending the information and a sample Non-MS link.

Q. Don Vanier wants to create a Guest Book with FrontPage 98.

A. In the FrontPage 98 Editor, select File.New from the menu and choose Guest Book as the page type.

Q. Jorge Ituarte wants to create a file data source name (DSN).

A. See Creating a File DSN Non-MSDN Online link.

Q. Kai-Min Lin wants to build a search engine.

A.Front Page 2000 has a search bot that allows you to set up a search form for your Web site. Or use the Indexing Service of Windows NT Non-MSDN Online link.

Q. John Fisher wants to know what technologies the Microsoft Internet Explorer supports for Microsoft Windows CE.

A. See Internet Explorer for Windows CE.

Rafael M. Muñoz, when not playing or coaching his favorite pastime (volleyball), provides technical assistance as a full-time developer support engineer for Microsoft Developer Support.

Thomas Moran, when not struggling to maintain some semblance of sanity (working with Rafael certainly doesn't help), toils with a prodigious team that creates articles and other content from Microsoft's Developer Support.



Back to topBack to top

Did you find this article useful? Gripes? Compliments? Suggestions for other articles? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.