Solved

dbconn in global.asa

Posted on 2001-07-18
3
561 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Want the count number from this QUery 2 54
Server Timeout with Loop 6 52
Hide cell in a table 2 27
Hide Table in merge 3 32
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 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