Solved

dbconn in global.asa

Posted on 2001-07-18
3
551 Views
Last Modified: 2008-02-01
hi,
i am getting a type mismatch trying to
<%
Call OpenDB()
%>

here is the function, what am i missing ??

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">


Dim rs, dbConn

Function OpenDB()
     Set dbConn = Server.CreateObject("ADODB.Connection")
     dbConn.ConnectionTimeout = 15
     dbConn.CommandTimeout = 30
     dbConn.Open Application("dbConn_ConnectionString")    

End Function

Function CloseDB()
     ' close cursor and database connection
     Set rs = Nothing
     if ucase(TypeName(dbConn)) = "OBJECT" then
          dbConn.Close
          Set dbConn = Nothing
     end if
End Function


</SCRIPT>
0
Comment
Question by:neostudio
  • 2
3 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6295963
My guess is this line

dbConn.Open Application("dbConn_ConnectionString")    

What is this  <<Application("dbConn_ConnectionString")>>
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6295967
Oh, I get it! you are trying to connect in your global.asa without exposing your connect string.  I've read some serious no no's about doing that!  I think you are just now finding some of the problems with it...
0
 
LVL 5

Accepted Solution

by:
dgorin earned 25 total points
ID: 6296415
The function appears correct.  Looks like it's using an Interdev created connection?

Change the function to a sub.  Your 'call openDB()' isn't correct.  A function returns a value and you're not putting it anywhere.  Try

<%
Call OpenDB%>

here is the function, what am i missing ??

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">


Dim rs, dbConn

Sub OpenDB()
    Set dbConn = Server.CreateObject("ADODB.Connection")
    dbConn.ConnectionTimeout = 15
    dbConn.CommandTimeout = 30
    dbConn.Open Application("dbConn_ConnectionString")    

End Sub

Sub CloseDB()
    ' close cursor and database connection
    Set rs = Nothing
    if ucase(TypeName(dbConn)) = "OBJECT" then
         dbConn.Close
         Set dbConn = Nothing
    end if
End Sub


</SCRIPT>
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now