|
|
|
|
|
| | |
|
Active Server Pages help tutorial how to ASP Help ASP Tutorials ASP Programming ASP Code - ASP Free CJWSoft ASPProtect ASPBanner ASPClassifieds
(Advanced)
(Components)
(Database)
(General)
(Vbscript)

|
|
Subject: |
Opening MSAccess Db from ASP function |
From: |
Wends |
Date: |
1/31/2001 10:58:06 AM |
IP: |
213.123.61.53 |
Hi,
I was wondering if anyone could help me. I have created the function openDbConnection as shown below:
Function openDbConnection()
' Declare all variables required
Dim objConn ' Holds the object connection
Dim strConnection ' Holds the connection string
' Define the type of connection
Set objConn = Server.CreateObject("ADODB.Connection")
' Set the connection string and database name
strConnection = "DSN=cdmt;Database=testcdmtDb;"
' Set the username and password
strConnection = strConnection & "UID=sa; PWD=;"
' Open the database connection
objConn.Open strConnection
' Set the return value for the function
openDbConnection = objConn
End Function
Now everytime I want to open the database connection I am making a call to the function as
objConn = openDbConnection()
But when I try to execute a query using the objConn I get an error stating:
Microsoft VBScript runtime error '800a01a8'
Object required: 'objConn'
Is it not possible to open a db connection in this way - if not then are there any suggestions for how I open a db at script level - in a tidy manner??
Many thanks
Wends |
|
|

|
|
|
|
|
|
|
|
|
|