473,394 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Late binding with ADO and adModeShareExclusive problem

Hi Guys,

I am having a problem with a late binding conversion with ADO. I have
the following sub which is designed to be passed an ADO connection
object and also the full path to the .mdb file, then if the file
actually exists attempt a connection to it.

Sub ConnectMDB(ByRef connector As Object, ByVal filename As String)
Set connector = Nothing
Set connector = CreateObject("ADODB.Connection")
If FileExists(filename) Then
'Set connector = New ADODB.Connection
With connector
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source = " & filename & ";"
.Mode = adModeShareExclusive
.Open
End With
End If
End Sub

There seems to be an issue with the adModeShareExclusive. When I try
and use the code I am receiving a 'Variable not defined' on the mode
setting (it is highlighted) and the execution stops on the first line
of the sub. It works fine when the reference exists, but not without
it seems.

Any ideas?

The Frog
Jun 27 '08 #1
3 4693
Greetings,

It looks like you already tried

Set connector = New ADODB.Connection

What are you trying to accomplish? ADO is mainly for
connecting/Interfacing to/between an mdb and sql server or an mdb and
Excel (or possibly a text file), or from Classic VB (VB6) to sql server,
or an mdb, or excel...

If you are trying to use ADO between mdb's you are better off using DAO
- the native data construct of the mdb.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #2
If you have a ref to ADODB you don't need late binding.
If you haven't, how could Access/VB know what adModeShareExclusive
is(12)?

I`ve been using ADO connections for more than ten years and I have
never yet wanted an exclusive connection. Then again I`ve never used
it to connect to an MDB.

These lines are nuts:
Set connector = Nothing
Set connector = CreateObject("ADODB.Connection")
If FileExists(filename) Then
'Set connector = New ADODB.Connection
Why would you create the connection twiceÉ (É = question mark ... so
my keyboard is screwed up! Tant PIS!)
If you`re going to set the connection to something why would it matter
if it`s nothing or not nothingÉ

The best code is always short, simple code despite the dream sequences
of MS programmers and MVPs. Clearly, they are paid by the line.

On Jun 25, 11:31*am, The Frog <Mr.Frog.to....@googlemail.comwrote:
Hi Guys,

I am having a problem with a late binding conversion with ADO. I have
the following sub which is designed to be passed an ADO connection
object and also the full path to the .mdb file, then if the file
actually exists attempt a connection to it.

Sub ConnectMDB(ByRef connector As Object, ByVal filename As String)
Set connector = Nothing
Set connector = CreateObject("ADODB.Connection")
If FileExists(filename) Then
* * 'Set connector = New ADODB.Connection
* * With connector
* * * * .Provider = "Microsoft.Jet.OLEDB.4.0"
* * * * .ConnectionString = "Data Source = " & filename & ";"
* * * * .Mode = adModeShareExclusive
* * * * .Open
* * End With
End If
End Sub

There seems to be an issue with the adModeShareExclusive. When I try
and use the code I am receiving a 'Variable not defined' on the mode
setting (it is highlighted) and the execution stops on the first line
of the sub. It works fine when the reference exists, but not without
it seems.

Any ideas?

The Frog
Jun 27 '08 #3
Hi Phil,

Thanks for the response. I would have liked to use DAO, however the
circumstances prevent me from doing so. Most of the machines I have to
work with are running Access97, and the database format is 2000/XP/
2003. The option to upgrade the DAO on these machines does not exist.
They are running windows XP, so ADO 2.8 is present by default.

The idea, as you can see, is to connect to an MDB file, regardless of
97 format or newer (except for the newer still ACCDB - dont need to
worry about that at the moment). I need to set this all to late
binding and eliminate dependencies throughout the app. I havent come
across this issue before, and for the operations that will take place
I must ensure that the connection to the DB is exclusive.

I will keep working on this, and if you can think of anything that
would help then please let me know.

Cheers

The Frog
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Mike MacSween | last post by:
Had some trouble with Word automation. Sorted it, in the process thought I would try late binding. Some people reccomend it. So this: *********************************************************...
1
by: JD Kronicz | last post by:
Hi .. I have an issue I have been beating my head against the wall on for some time. I am trying to use late binding for MS graph so that my end users don't have to worry about having the right...
7
by: PC Datasheet | last post by:
I have this: Dim Cbr As Object Dim Ctl As Object Set Cbr = Application.Commandbars("CourseCalendarMonth") Set Ctl = Application.Commandbars("CourseCalendarMonth").Controls("CalendarMonth") Is...
14
by: Composer | last post by:
I've read many postings about the problem of Access.References.IsBroken and the consensus seems to be that late binding is the cure-all. I have a very complex Access application that needs...
9
by: Zlatko Matiæ | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
8
by: scorpion53061 | last post by:
I am sorry for this but I am not getting an answer elsewhere so I thought I would try here. It seems the safer way to go prior to deployment is to change my early binding to late binding to...
30
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
6
by: Tim Roberts | last post by:
I've been doing COM a long time, but I've just come across a behavior with late binding that surprises me. VB and VBS are not my normal milieux, so I'm hoping someone can point me to a document...
14
by: Siv | last post by:
hi, I am converting an application that writes to an Excel spreadsheet and the code trips the "option Strict" that I would like on because the parser says "option Strict On disallows late...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.