SQL in a "direct" Way

I wonder if it's possible to communicate to an MDB (MS-Access) directly, by specifing the path to that file, without using an ODBC or BDE-Connection, like you can do it in Visual Basic ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nope (well not that I know of)

The Neil
omsecAuthor Commented:
well then...how to programmatically add an ODBC-Connection ?

Because it's not that good, if all people have to set up this stuff before the program may run.
you can specify the path and not have to use odbc or bde  but you need something like diamond access from here:
that talk straight to the jet dao engine.
these comps are great for access (can change dao version in object inspector to talk top either access97 or access2000 .very easy to use etc..
Regards barry


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

omsecAuthor Commented:
but there is no way of using the SQL-Capabilities of a TQuery ?
omsecAuthor Commented:
is it possible to add an ODBC-Connection for MS-Access programmatically ?
hi ,
i found this ,it may do what you need but i have not tested it:

The following will set up the ODBC driver as a datasource:
const ODBC_ADD_DSN = 1;
function SQLConfigDataSource( hwndParent: hwnd;
    fRequest: Word;
    lpszDriver: PChar;
    lpszAttributes: PChar): Boolean; stdcall; external 'odbccp32' index 6;

Once you have done that, use the following:

hwndParent := 0;    { so we don't get the annoying configuration window.}
fRequest := ODBC_ADD_DSN;   { This will add the datasource if it isn't
already there,
        and will over-write the datasource if it is already there.}
lpszDriver := 'Microsoft Excel Driver (*.xls)' + #0; { As an example,
though could be for any ODBC driver.}
lpszAttributes := 'DSN=abcdef' + #0 +  { abcdef is the name you give the
  'DriverID=22' + #0 +  { Excel specific, need to look into the driver you
are using.}
  'FIL=excel 5.0;' + #0 +  { Again, refer to your driver.}
  'DBQ=xxxxxx' + #- +  { This is the file being opened.  Again refer to
your driver.}
  'DefaultDir=xxxxxxxx' + #0 + #0; { Yep, again refer to your driver.
These are just the parameters
        that Excel needs.  Each driver will be different.  The key is to
        separate each with a #0, and finish it all of with #0 #0.  The MS
        Help file is pretty good in this area, though the information is
        and is only of help for the MS datasources.}

Call the routine with

if SQLConfigDataSource( hwndParent, fRequest, @lpszDriver[1],
then {we were successful}

From a data access point of view, do the following:

AliasName = 'abcdef' { Same as the DSN setting above.}
DatabaseName = 'odbc_MyDatabase'

TQuery or TTable
DatabaseName = 'odbc_MyDatabase'

Once you have done this, it's as though you have a normal BDE connection to
the ODBC database.  I have found that not all ODBC databases support the
expected SQL standard, so you may need to look out for that.
omsecAuthor Commented:
well, most of the things of that API-Proc are OK, but i don't know what you mean by "refer to your driver"

I couldn't findout those Parameters, DriverID, FIL and DefaultDir. I'm also not sure if the MS Jet Database is installed on my local Workstation or on a Server of this LAN.

I just saw File Info on the MS-Access Driver, such as File Version and location, company info etc.
I'll b thabnkfull for some additional info on this.
i found most of them via control panel "odbc datasources" then just select one(friver) and click the configure button ,then the advanced button (note the advanced buton doesnt appear on all of them but it did on my MSaccess ones.
note :
some including driverid were blank so it seems they may not all be nesessary.
omsecAuthor Commented:
well, one quite important parameter is:
where do i specifiy the MDB-File to be used for this Alias ?

So far, the Proc works, but it add a "void" Alias.
omsecAuthor Commented:
ok, forget the last comment...
i found it in the Help File which is very nice, hehe

it works just fine
omsecAuthor Commented:
so, its time to "pay" you :P
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.