Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 10th, 2003, 12:09 PM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default global.asa and dreamweaver connection

I'm desperate... I have a site that has a hand coded section that runs a mini B2B auction system (written by someone else). To make the connection to the SQL server it uses a file called global.asa

It works great and I got it to interface with my part of the Dreaweaver ASP site fine. The problem is now I need to access a second database for some of my pages. As long as that global.asa file is there it will not make a connection, via DSN or a connections script. It just says unknown error. If I rename or remove that file, it makes the connection but the rest of the site does not work. I need to have the connection for my part of the site because there is a place on every page of mine that the users log into the auction.

any ideas ? PLEASE

 
Old October 10th, 2003, 01:54 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You could add the general connection code inside another ASP file, lie Connection.asp. Then you can include this file in other pages that require it. In those pages, you can, for example, open the Connection, retrieve a recordset and close the connection again. This way, the general code (like the connection string) is all in once place.

If you do have to put your code in the global.asa file (depending on where in the global.asa you create your connection this may not be very recommended), I suggest you post the code for it, so maybe we can suggest place to put your new connection code.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 10th, 2003, 02:24 PM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Below is the code provided.

I have narrowed the error not allowing me to make other normal Dreamweaver connections to the code :
" if redirecturl <> "" then
                response.redirect redirecturl
            end if
            response.end
"
but I don't know how to fix it.

____________________________
<OBJECT RUNAT=Server SCOPE=Session ID=MyInfo PROGID="MSWC.MyInfo">
</OBJECT><SCRIPT LANGUAGE=VBScript RUNAT=Server>
    Sub Session_OnStart
        app_location="aspre"

        ' figure out who's coming in and where they belong
        session("url")=request.servervariables("URL")&"?"& request.servervariables("QUERY_STRING")
        if instr(session("url"),"distrib")>0 then
            login_status="distributor"
        elseif instr(session("url"),"purchaser")>0 then
            login_status="purchaser"
        elseif instr(session("url"),"cart_func")>0 then
            session("startshopping")=true
        elseif instr(session("url"),"admin")>0 then
            login_status="administrator"
        elseif instr(session("url"),"cron.asp")>0 then
            cron = true
        else
            login_status="index"
        end if
        if login_status="index" then
            redirecturl=cstr(Application("serverpath")&"defaul t.asp")
        elseif cron then
            redirecturl = ""
        elseif login_status="distributor" or login_status="purchaser" then
            redirecturl=cstr(Application("serverpath")&login_s tatus&"-login.asp")
        else
            redirecturl=session("url")
        end if

            Application("connectstring") = "DRIVER={SQL Server};SERVER=server;database=test;dsn=test;uid=t est;pwd=test"
            Application("server")="http://www.test.com"
            Application("serverpath") = "http://www.test.com/auction/"
            Application("fromaddr") = "[email protected]"
            Application("cronnotify") = "[email protected]"
            ' get admin email in functions.asp
            'Application("adminemail") = "[email protected]"
            Session("timeout") = 600
            if redirecturl <> "" then
                response.redirect redirecturl
            end if
            response.end
        end if
    End sub
    Sub Session_OnEnd
        response.write "Sorry, your session has expired!"
    End sub
</SCRIPT>

 
Old October 10th, 2003, 05:31 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I noticed a few things in your post:

First of all, you may need to enable more detailed error messages in either your browser, or at the server (or both). For the browser (IE), open the Options panel, switch to the Advanced tab and disable Show friendly HTTP error messages. For IIS, open your site, click the Configuration button on either the Directory or Home Directory tab, and then switch to the Debugging tab. Make sure that Send detailed ASP error messages to client is checked.

Once you do that, you'll probably get an error like this:
Code:
Microsoft VBScript compilation error '800a03f8' 

Expected 'Sub' 

/YourSite/global.asa, line 42 

end if
----^
Once you look at like 42, you'll see that you have one End If too much. Once you remove it, the global.asa is OK, and your pages will run fine. At this point, you could add additional connection strings in the Application scope.

The last thing I noticed is the Session_OnEnd. This event will fire when the session times out or is destroyed. This means that the user is no longer connected. So, even if you have a Response.Write statement there, your client will never see the "Sorry, your session has expired!" appear.

Hope this helps,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 11th, 2003, 10:06 AM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Imar,

That was a huge help! I have things working great now.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Global.asa pushpa Classic ASP Basics 19 March 9th, 2007 08:30 AM
global.asa vin_0x1 Classic ASP Components 2 July 24th, 2006 01:13 AM
Global.asa gmoney060 Classic ASP Basics 3 September 25th, 2004 09:11 AM
Global.asa madsmad ASP.NET 1.0 and 1.1 Basics 1 August 17th, 2003 07:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.