Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODC runtime error

Status
Not open for further replies.

b4bala

Technical User
Dec 7, 2001
6
US
My application has 5 forms each with a datagrid control and adodc control linked to a common access database (.mdb). When I run this application more than 10- 15 times either from VB development enviroment or as an exe, I get the following runtime errors.
1. Unspecified error.
2. Runtime error '-2147467259 (80004005)
Method 'Refresh' of object 'IAdodc' failed.

This what microsoft website has to say about it...
"
They talk about multiple instances.., but I donot deal with multiple instances of the same application at the same time.
At any time there is only one instance of the application running.

Do anybody knows any way to avoid this error?
Thanks in advance.
Bala
 
Are you unloading all the forms (e.g. Unload Me, Unload Form1, etc.), and any objects (e.g. Set Object = Nothing) you create when you stop the application. Just using End will leave stuff behind that may cause problems if you run the app many times without a reboot.

rgds
Andy
 
Yes, I close the the connection to the database (.mdb) by using the following statement when I exit the app.

DataEnviroment1.Connection1.Close

Other than this, I donot do any thing with the Adodc(s). I think this statement takes care of them..doesnt it?

Thanks for ur promt response.
Bala
 
Are you declaring any data objects, such as:
Dim cnn = ADODB.Connection
Dim rst = ADODB.Recordset

Set cnn = ...
Set rst = ...

If so, are you setting them to 'Nothing' when you are done with them, e.g.
Set cnn = Nothing
Set rst = Nothing

How are you quitting your application, and are any forms still loaded, but hidden when you do. Unload all loaded forms when you are done with them to ensure that nothing is left behind in memory that may still have a connection to the .mdb

Other than those suggestions, I've got no idea, and Q307640 offers little guidance, other than suggesting migration to SQL Server :-(

rgds
Andy
 
Thanks Andy.

I donot declare these objects as shown by you.
I have added DataEnvironment Object to my project. Then,I use
DataEnvironment1.Connection1.ConnectionString = "..."
DataEnvironment1.Connection1.Open

And I donot use recordset objects. I use Adodc objects for the DataGrid objects in the form. Then I connect Adodc to mdb using connectinString propery.

I tried unloading all forms explicitly, but its not working.
Earlier, I used "End" to end application when any form was closed, I hope this closes the applicatioin and unloads every thing.

Is there any way to disconnect Adodc from mdb? Because I donot do any such thing explicitly. But the program runs well for 1 to 10 run(s). Only after that it gives error.

Anyway, thanks.
Bala

 
Hi b4bala

I'm having the same issue..did you get to solve it...

If you did can you please email with your results:

gerard_gallagher@health.qld.gov.au

Thanks!!

Gerard
 
Hi All!


I am having the same problem. Please let me know how this can be resolve too


thanks


Kay
 
I am connecting to a Access 2000 database using a ado control. As each form is loaded I make my connection programatically and the Close each connect as I leave.

Private Sub Form_Load()
Dim FileFinder As String
XDrive = txtExternalDrive.Text
F2 = "*.*"
F3 = "\"
On Error GoTo ErrorForm

'//Programatic ADO Connection
'//Define the properties for the connection object
'//then open the connection.
pconLogin.Mode = adModeShareDenyNone
pconLogin.CursorLocation = adUseClient '//4.0 used to connect to Access 2000
pconLogin.Provider = "Microsoft.Jet.OLEDB.4.0"
pconLogin.ConnectionString = "Persist Security Info = False;" & _
"Data Source = C:\IE SOFTWARE MANAGER\SOFTWARE MANAGER.mdb"
pconLogin.Open

'//Define the properties for the command object.
Set pcmdLogin.ActiveConnection = pconLogin
pcmdLogin.CommandType = adCmdTable
pcmdLogin.CommandText = "Transactions" '//Name of table used

'//Define the properties for the recordset object then
'//open the recordset. The same recordset is used
'//while the form is open. Thus, a module level
'//variable is used.

mrstLogin.LockType = adLockOptimistic
mrstLogin.CursorLocation = adUseClient
mrstLogin.CursorType = adOpenKeyset
mrstLogin.Open pcmdLogin
'//MsgBox "Your connection is open"
ReDim mvntBookmark(1) '//Initialize the array of bookmarks



'//As I Exit the pgm I call "CloseMe" Function to insure my connection is closed.

Private Sub cmdExit_Click()
Call CloseMe
frmADMIN.Show
Unload frmMasterFileSM
End Sub


Public Function CloseMe()
pconLogin.Close '//used to insure connection is closed as needed for pgm.
'//MsgBox "Your connection has been closed", vbOKOnly
End Function


I know this is simalar to what others have already said but hope this may be of some help.

 

Try to use the same connection object for all recordsets, and action queries done on the same MDB.

This may mean creating recordset objects where ever you would use an ADODC, replacing the ADODC with the recordset object.
Or at least removing the connection and recordsource properties from the ADODC, creating a connection object(global), and recordset object(local) in code, and then assign the Adodc1.Recordset to the recordset variable object.
Not too much extra work, and the benefits will great.

Also, make sure when you are done with a recordset or connection object you first Close it and then set it to nothing.

This should solve most of the problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top