View Single Post
  #1 (permalink)  
Old September 10th, 2004, 08:17 AM
patzblue patzblue is offline
Registered User
Join Date: Sep 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with ASP and MS ACCESS. Connection error.

Hi. I have a project using ASP to connect to an Access Database.

Randomly, I get the error "The connection cannot be used to perform this operation. It is either closed or invalid in this context.".

It's not constant though. Works nice for a week, then I get that error. Does anybody know a way to validate if the connection is on ? I am not an advanced ASP programmer so any help would be more than appreciated. I assume there might be something wrong in my connection string, either that or the settings of the Access Driver on the server. I changed the timeout on the driver and the buffer size, but without any success. Here's my ASP script :

<% Session.CodePage = 65001%>
Dim strSystemDSNName
Dim strDatabaseName
Dim oConn
Dim rs
Dim strSQL
Dim strKey

on error resume next

'************************************************* ****************
strSystemDSNName = "xxx-c5a"
strDatabaseName = "D:\Inetpub\xxx_Database\xxx-c5a.mdb"
'************************************************* ****************

'Request object variables
strKey = Request.Form("Key")

'use request object to build SQL statement
strSQL = "select * from " & "DSCs" & " where dsc_name='" & strKey & "'"

'Create the connection object
Set oConn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")

'open the connection to database "Provider=MSDASQL.1;Persist Security Info=False;Data Source="& strSystemDSNName & ";Initial Catalog=" & chr(34) & strDatabaseName &chr(34)

rs.Open strSQL,oConn,adOpenForwardOnly,,adCmdText

thanks a lot.


Reply With Quote