Visual InterDev For Dummies and
Active Server Pages For Dummies

Questions and Answers

If you have a question, just email it to me by clicking here . If I know the answer, I'll post it along with the question for others to see. If I don't, I'll post the question and give others a chance to answer the question by sending me email. I'll post all the answers I get. Hopefully one of them will work for you.

 

QUESTION:

I try the The Cafe asp in your "ASP for Dummies" and I got the following error. Did I miss something on the server?

Application object error 'ASP 0197 : 80004005'
Disallowed object use /cafe/default.asp, line 29
Cannot add object with apartment model behavior to the application intrinsic object.

Jammy L. (and many others)

ANSWER:

I have received two very good descriptions from readers describing why this is a problem and how to fix it. The first response does a good job of describing why the problem exists and the second response does the best job of providing a work-around. Here they are:

First Response:

(I'm) writing to let you know of a problem with one of the scripts in the book due to a recent change in ASP from microsoft. In the following code from "The Cafe" chat room example, you define a scripting dictionary(using VB Script) on the application level:

if not isobject(application("users")) then
application.lock
set application("users") = server.createobject("scripting.dictionary")
application.unlock

This (code) worked fine until recently. With the introduction of Visual Basic 6, the registration key for the scripting dictionary threading model was changed from "both" to "apartment" - after the value of the key is changed, when you attempt to run the script, you get the following error at the line that attempts to create the dictionary object:

Application object error 'ASP 0197 : 80004005'
Disallowed object use /Login.asp, line 25
Cannot add object with apartment model behavior to the application intrinsic
object.

The following is the text of the Microsoft knowledge base article on this error:

CAUSE

The Dictionary object's threading model is incorrectly set to "Both" in the registry when Internet Information Server (IIS) 4.0 is initially installed. This is documented in the IIS documentation, which also includes instructions to update the ThreadingModel registry key. When Visual Studio 6.0 is installed it updates/corrects the threading model of the Dictionary object, setting it to "Apartment."

RESOLUTION

To work around this problem, create all global Scripting.Dictionary objects with a session scope as follows:

   <%Set Session("SD")= Server.CreateObject("Scripting.Dictionary")%>

STATUS

This behavior is by design.

REFERENCES

Please refer to the following Windows NT 4.0 Option Pack Product Documentation for Scope and Threading guidelines:

   Microsoft Internet Information Server       Programmers Reference          Creating Components for ASP             Planning for Component Development                Component Design Guidelines

Please refer to the following Windows NT 4.0 Option Pack Release Notes for information on the Scripting.Dictionary object registry key:

   Internet Information Server Version 4.0 Release Notes

You'll notice that the so-called resolution doesn't solve the problem: creating the dictionary on the session level does not make it available to all users. One possible solution would be to use the JavaScript Array object since they work with key/value pairs. It also doesn't require the overhead of creating the object. Or if you have Commerce Server installed, you can replace the Scripting.Dictionary with the Commerce.Dictionary, which is 'both' threaded. Otherwise, they have the same functionality.

BTW, you can also receive this same error message number when installing the microsoft transaction server, but the two problems are unrelated.

Curt H.

Second Response:

I was able to get your source code for the auction site and classified ads site working without any problems. However, the chat room application had a problem. Specifically, line 29 of default.asp generated an error message because it tries to assign an "apartment" object to an application level variable (the variable "users").

Although I'm certainly not an expert programmer, I did some searching around on Microsoft's website and found some references to the use of the word "apartment" in programming contexts. Apparently, it refers to a specific type of threading model implemented in COM or ActiveX (I'm not clear about these distinctions). So, I came to believe that I needed to force the Server.CreateObject method to return an object that was not apartment threaded.

I therefore declared an application-scope variable called varDictionary in the global.asa file using the following code:

<OBJECT RUNAT=Server SCOPE=Application ID=varDictionary PROGID="Scripting.Dictionary">

</OBJECT>

And then changed line 29 of Default.asp to read:

Set Application("users") = varDictionary

After making these two changes, the program would run. Thus, apparently the declaration in global.asa using the <OBJECT> tag was necessary in order to overcome the apartment-threaded limitation.

Mike P.

 

QUESTION:

But I am confused in the Classy Classifieds source code. You have in the source code the following:

<!-- #include virtual="common/adovbs.inc"-->

Did you forget to include the file "adovbs.inc" with the book? I can not find that file or any reference in your text about it.

Bob C.

ANSWER:

You should have this file already. A likely place to find it is in this folder: c:\Program Files\Common Files\System\ADO.

If you don't have any luck there, try searching your entire system for the file by clicking Start -> Find -> Files or folders. Be sure the Include subfolders checkbox is checked.

If you still come up empty handed, I've got the file on my Web site for you to download. It's at:

http://www.edgequest.com/common/adovbs.inc

 

QUESTION:

I'm running PWS installed with FrontPage 98. I made the Launch Page as you suggested (in notepad) and used the Boiling Water example as my first test. When I open the Launch with IE and click on boil.asp FrontPage Editor launches and opens the file (boil.asp). Yes I saved boil.asp in the wwwroot. Yes the PWS is running. However the page doesn't run correctly. So what's the problem? What's the fix?

ANSWER:

The PWS will not accept ASP pages unless the ASP.EXE is installed. This file is not automatically installed as it is on IIS, so many of your readers who are trying to upgrade from FrontPage 98 will encounter some definite difficulties. I spent an entire day trying to figure out why the FrontPage Editor kept opening up every time I tried to view an ASP example in my browser.  I finally broke down and visited the dreaded Knowledge Base at Microsoft and found out what I was missing. 

ASP.exe is available for download from Microsoft and does come in the service pack with FrontPage 98.

Chris B.

ANOTHER ANSWER:

I'm using FrontPage 98, an Access DB and PWS for development. My version of PWS needed to have the ASP engine screwed in --- I read that in your Web updates -- from somebody named Chris B --- that was good to find out! Saved me a lot of time !

But it didn't solve my problem completely!! Still did the same thing (save ASP file)! So I went looking in the dreaded Mickeysoft black hole ! Here's what I found for FP with ASP pages :

To Create ASP pages in FP98 : In FP Explorer, open any (new or existing) Web site. In folder View -- go to the root folder -- right click and go to Properties, Select checkbox for " Allow scripts or programs to be run." Then get out. It should apply to all the sub directories.

You need to do this for each Web site (either new or when converting an existing Web )! In FP Editor: Open a page in the Web. On the Insert menu, point to Advanced and then click Script. In the script dialog box, click VB or Java Script then click the checkbox for "Run script on server." Close out the dialog box. This should remain the default for all pages afterward.

Now ya oughta be humming !

- Hal

QUESTION:

When I use the examples from the book (Chat & Classifieds --anything with a global.asa file) -- it crashed on the first line. The error message says that it doesn't like the progID of MyInfo. Any help here?

- Hal

ANSWER:

My work around consisted of deleting everything in the file, then adding the first 2 subroutines from your listing of the typical global.asa file (Pg. 156).

- Hal

QUESTION:

I'm working on an NT server with IIS 4 and an Access 97 db. I'm using the ODBC drivers from MDAC 2.0. I am able to pass an argument from page to page using the ?Variable=(String) construction. I am also able to build a SQL statement to query my database. However, when I leave a "?" for the search criteria and enter the code to pass the variable from the previous page (in the onbeforeupdate method of the record source) I get the following message in my browser (IE 4.01):

Microsoft OLE DB Provider for ODBC Drivers error '80040e51'
The provider cannot derive parameter info and SetParameterInfo has not been called
/Mnemonic/_ScriptLibrary/Recordset.ASP, line 456

My initial interpretation was that you cannot pass parameters this way to Access. Is this correct, or might I have missed something? If you cannot perform this operation with Access, I think you really should have a warning stating so, as this severely limits your ability to use Access for Web apps where all but the simplest queries are needed. If there is a way to perform this operation in InterDev using DTC, or even writing my own ASP scripts, I'd appreciate the info.

Thanks.

Jason W.

ANSWER:

I'm happy to say that I found an article that addresses your question directly: Creating updatable parameterized queries using an Access database. From the looks of the article, you aren't the only one who's struggled with this one!

http://www.15seconds.com/Issue/981013.htm

 

QUESTION:

I have a question for you on the Application Level Objects. I am creating Java objects (using set y = Server.CreateObject("Java Program Name") and then call the java methods of y object using y.method1(par1, par2, .....) ) However, I would like to create an Application level Java level object (a true object and not just name value pair). Using things like Application("JavaObj") = y does not work. Any ideas?

ANSWER:

I haven't worked with this one. Anyone else have an idea? If so, email me and I'll post your answer here.

 

Back To Table of Contents