PC Review


Reply
Thread Tools Rate Thread

Connection Cannot Be Used to Perform this Operation

 
 
alexcn
Guest
Posts: n/a
 
      8th May 2007
Hey there,

I am gettinga very frustrating error which, no matter what I try,
cannot be shifted. It is the dreaded "connection cannot be used" but
as far as I can see (and this has only suddenly stopped working) there
is nothing that has changed. The error appears when the condb.open
statement passes, giving "Unspecified Error" and then when the
recordset is opened usig this db connection. The code is as follows:

Dim conDB As ADODB.Connection

Const DatabasePath As String = "C:\Working\db1.mdb"

Sub SetUpConnection()
On Error GoTo Errhandler
Set conDB = New Connection
conDB.Provider = "Microsoft.Jet.OLEDB.4.0" 'Change to 3.51 for
Access 97
conDB.ConnectionString = DatabasePath
conDB.Open
Exit Sub
Errhandler:
MsgBox Err.Description, vbExclamation, "An error occurred"
End Sub

Public Function funcGetAcctDesc(strAcctDest As String) As String
Dim rsLookup As ADODB.Recordset
Dim strSQL As String
On Error GoTo Errhandler
If conDB Is Nothing Then SetUpConnection
If (strAcctDest <> "") Then
Set rsLookup = New ADODB.Recordset
strSQL = "SELECT tAcctMain.amCode, tAcctMain.amDesc " & _
"FROM tAcctMain " & _
"WHERE (tAcctMain.amCode = '" & strAcctDest & "') " & _
"ORDER BY tAcctMain.amCode DESC"
rsLookup.Open strSQL, conDB, adOpenForwardOnly, adLockReadOnly
If rsLookup.BOF And rsLookup.EOF Then
funcGetAcctDesc = ""
Else
funcGetAcctDesc = rsLookup.Fields("amDesc").Value
End If
rsLookup.Close
Set rsLookup = Nothing
Exit Function
Else
funcGetAcctDesc = ""
End If
Exit Function
Errhandler:
MsgBox Err.Description, vbExclamation, "An error occurred"
End Function

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not Enough Memory to Perform the Operation Sam Microsoft Access 4 28th May 2008 05:49 PM
there isn't enough memory to perform this operation. =?Utf-8?B?cGlyc2Vpbg==?= Microsoft Access Queries 1 27th Feb 2006 06:19 PM
Cannot perform '=' operation =?Utf-8?B?YnVydGFtdXM=?= Microsoft ADO .NET 4 11th Jan 2006 06:55 AM
Could not perform this operation... Tim Green Microsoft Outlook 4 20th Jul 2005 02:44 PM
HELP - There isn't enough memory to perform this operation! RickN Microsoft Access Forms 0 16th Sep 2003 07:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:12 PM.