SQL in a "direct" Way

Hello,
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 ?
LVL 2
omsecAsked:
Who is Participating?
 
intheConnect With a Mentor Commented:
hi,
you can specify the path and not have to use odbc or bde  but you need something like diamond access from here:
http://www.islamov.com/diamond/downloads.html
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



0
 
TheNeilCommented:
Nope (well not that I know of)

The Neil
0
 
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.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
omsecAuthor Commented:
but there is no way of using the SQL-Capabilities of a TQuery ?
0
 
omsecAuthor Commented:
is it possible to add an ODBC-Connection for MS-Access programmatically ?
0
 
intheCommented:
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:
 
----------------------------------------------------------------------------
-------
 
implementation
 
const ODBC_ADD_DSN = 1;
ODBC_CONFIG_DSN = 2;
ODBC_REMOVE_DSN = 3;
 
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
datasource.}
  '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
Jet
        Help file is pretty good in this area, though the information is
buried,
        and is only of help for the MS datasources.}

Call the routine with

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


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

TDatabase
----------------
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.
0
 
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.
0
 
intheCommented:
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.
0
 
intheCommented:
note :
some including driverid were blank so it seems they may not all be nesessary.
0
 
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.
0
 
omsecAuthor Commented:
ok, forget the last comment...
i found it in the Help File which is very nice, hehe

it works just fine
0
 
omsecAuthor Commented:
so, its time to "pay" you :P
0
All Courses

From novice to tech pro — start learning today.