Solved

Problem with MS Access

Posted on 2002-04-15
13
236 Views
Last Modified: 2010-05-18
Can anyone tell me what I should be looking for when I get an error message "[Microsoft][ODBC Microsoft Access Driver] Internal OLE Automation Error"

This appears only in my executable not in the design environment and appears to happen with this code

Set tmpRecordset = New ADODB.Recordset
TmpSQL = "SELECT USER_LOGIN_NAME, USER_LOCKED FROM Users"
TmpSQL = TmpSQL & " WHERE USER_LOCKED = TRUE"

tmpRecordset.Open TmpSQL, sConnection, adOpenKeyset,adLockOptimistic

0
Comment
Question by:mutrus
  • 3
  • 3
  • 2
  • +4
13 Comments
 
LVL 6

Expert Comment

by:xSinbad
ID: 6943908
How about Dim tmpRecordset as New ADODB.Recordset instead of Set tmpRecordset = New ADODB.Recordset.


Cheers
Marcus
0
 

Expert Comment

by:cjzone81
ID: 6944117
Did u test ur connection string for the sConnection u declare?
0
 
LVL 3

Expert Comment

by:Rem
ID: 6944180
Looks like a bad entry in the registry to me.
If I were you, I'd try to unregister msado15.dll (for ADO activex control 2.7) and re-register it.

Marcus, I guess mutrus has a global declaration for the ADODB.recordset, and therefor uses the Set syntax.

cizone81, mutrus wouldn't have the same error message, and besides, his program wouldn't run in tne design environment.

C U

Rem
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Expert Comment

by:clangl
ID: 6944489
I think REM is right, OLE automation error... I would start with the dll or maybe the version of MDAC you are using and if you are using a form check the components you are using.  I know I had the same problem awhile ago but it was when I was exporting a bunch of data to an Excel Worksheet
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6944801
try to use this to create a recordset :
dim tmpRecordset as ADODB.Recordset
Set tmpRecordset = CreateObject("ADODB.Recordset")

this may give you a better error.


to xSinbad  - it's bad idea to declare something with new.

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6944903
Just a guess:
Try with
Set tmpRecordset = New ADODB.Recordset
TmpSQL = "SELECT USER_LOGIN_NAME, USER_LOCKED FROM Users"
TmpSQL = TmpSQL & " WHERE USER_LOCKED =" & BooleanValue

Where BooleanValue is a boolean variable True or False
0
 
LVL 6

Expert Comment

by:xSinbad
ID: 6946281
>to xSinbad  - it's bad idea to declare something with new.

I personally would not use new either but that is what mutrus was doing. I personally would never use ADO but that is not for me to tell others what to do. If mutrus wants to use Dim tmpRecordset as ADODB.Recordset then that is also an option.

Regards
Marcus
0
 

Expert Comment

by:cjzone81
ID: 6946723
Marcus,i always use this when i try to connect to the database.
dim rst as adodb.recordset
'this is on top of the page

set rst = new adodb.recordset
'n i'll use this to create an instance when i need to store data anywhere in the page.
'n i'll close it too whenever i've finished using it.

but why is it bad to declare something with new?
n just now u said u will not use the ADO,why?
what other option did u turn to?
0
 
LVL 3

Expert Comment

by:Rem
ID: 6947032
The keyword New is optional. It enables implicit creation of an object. If you use New when declaring the object variable, a new instance of the object is created on first reference to it, so you don't have to use the Set statement to assign the object reference.
xSinbad: are you still using RDO?  LOL

Bye

Rem
0
 

Author Comment

by:mutrus
ID: 6947290
Thanks guys thats something to look at.

Yes the recordset is declared globally.

One other thing thought. I'm sorry that I forget to mention it but the error does not occur with the exe file on the same PC as the design environment. It happens on the clients PC.

Also it appears that I'm not using msado15.dll (ADO ActiveX 2.7) but ActiveX 2.1 which uses msado21.tbl - how do I register/unregister this (if its possible). This is my first attempt at writing VB with database access so much of what I'm using come from looking at other peoples apps.

0
 
LVL 3

Accepted Solution

by:
Rem earned 100 total points
ID: 6947304
How did you install your exe on the other machine?
Did you just copy the exe, or did you use the deployment wizard shipped with VB?
If you did use the deployment wizard, did you include the mdac, or at least the libraries you used to access the database in your project?

btw the usage of regsvr32.exe :
regsvr32 /u thedllyouwanttoUNregister
regsvr32 thedllyouwanttoregister

Bye

Rem
0
 

Author Comment

by:mutrus
ID: 6948912
I did initially copy the exe file as the target pc already has the vb development app which I had already used for my app and so the required files were there. I followed your suggestion though and used the deployment wizard which when run gave me an error that there was a problem with regestering msado21.tlb. I then uninstalled my app, changed to msado15.dll and reinstalled it using the installation package. This appeared to re-install the MDAC and now it all works. Thanks everyone
0
 
LVL 6

Expert Comment

by:xSinbad
ID: 6949227
cjzone81 I always use DAO instead of ADO. Just my preference.

Cheers
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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