Access 97/2000 and connection problem 
Author Message
 Access 97/2000 and connection problem

Hi all

I have a problem that no doubt has a simple solution, but before I get to
that perhaps someone can clear things up for me. From what I have read from
various sources I have got the impression that it is possible to connect to
an Access DB without using the BDE or ODBC. This is to be accomplished via a
TDatabase component. Is this true?

Whether this is true or not will no doubt affect my second question. Using
the above idea I am trying to connect to a .mdb that is in the same
directory as the program. The following properties have been set:

DriverName = Microsoft Access Driver (*.mdb)//though I have tried MSACCESS
LoginPrompt = False

I set the DatabaseName to the name of the database like so,

DatabaseName = db1.mdb

The problem is that when I try to connect the database at run time it gives
the following error message
"Invalid Parameter"

Can anyone tell me where I am going wrong? The ideal solution that I would
like to have is one where it is possible to simply cart the program and the
DB around where ever I want it, and not need to have to set up ODBC or BDE.
I would obviously needto take the DB support files with me as well.

--
~~~~~~~~~~~~~
?raig ?eynolds
~~~~~~~~~~~~~
Just becuase this is never going to work is no reason to be negative!



Mon, 06 Oct 2003 23:15:01 GMT  
 Access 97/2000 and connection problem
There are 3 ways to connect to a MS Access database:
1) Using ODBC
2) Using DAO (this is what the BDE MSACCESS driver is using)
3) Using ADO (this is what ADOExpress is using)

If you don't own ADOExpress (included in Delphi 5 Enterprise or available
separately for Delphi 5 Professional) you can use a third-party DAO or ADO
BDE replacement (see http://www.kylecordes.com/bag/index.html, I recommend
Diamond ADO, http://www.islamov.com/diamondado/index.html).

If you want to connect to MS Access using the BDE and ODBC you have to
create an ODBC DSN with the 32-bit ODBC Administrator (odbcad32.exe). Set
Database1.AliasName to the DSN and use different unique
Database1.DatabaseName.



Quote:
> Hi all

> I have a problem that no doubt has a simple solution, but before I get to
> that perhaps someone can clear things up for me. From what I have read
from
> various sources I have got the impression that it is possible to connect
to
> an Access DB without using the BDE or ODBC. This is to be accomplished via
a
> TDatabase component. Is this true?

> Whether this is true or not will no doubt affect my second question. Using
> the above idea I am trying to connect to a .mdb that is in the same
> directory as the program. The following properties have been set:

> DriverName = Microsoft Access Driver (*.mdb)//though I have tried MSACCESS
> LoginPrompt = False

> I set the DatabaseName to the name of the database like so,

> DatabaseName = db1.mdb

> The problem is that when I try to connect the database at run time it
gives
> the following error message
> "Invalid Parameter"

> Can anyone tell me where I am going wrong? The ideal solution that I would
> like to have is one where it is possible to simply cart the program and
the
> DB around where ever I want it, and not need to have to set up ODBC or
BDE.
> I would obviously needto take the DB support files with me as well.

> --
> ~~~~~~~~~~~~~
> ?raig ?eynolds
> ~~~~~~~~~~~~~
> Just becuase this is never going to work is no reason to be negative!



Mon, 06 Oct 2003 23:53:08 GMT  
 Access 97/2000 and connection problem
Ok, Lets get somethings clear first. When you use a tDataBase to connect to
a DB you are still using the BDE to connect, being the only difference the
fact that you just doesnt have a persistent connection listed in the IDAPI
configuration file, but a dynamic one.
To connect to an MSACCESS DB this way, you should proceed the following way:
1. Drop a TDataBase Component to your form.
2. Name it the way you want to.
3. In the Object Inspector choose MSACCESS as the DriverName (*Microsoft
Access Driver is the ODBC driver*)
4. Right Click the Database and choose load default parameters.
5. In the Object Inspector open the Params Property Editor.
Youll see something like this:
DATABASE NAME=DRIVE:/PATH/DATABASE.MDB <<<<<<<<*** fill in here with your db
fully qualified file name
USER NAME=
OPEN MODE=READ/WRITE
LANGDRIVER=
SYSTEM DATABASE=
The only mandatory parameter here is the DataBase Name. Append the full
path, including the MDB extension, to this line.
IN the object Inspector choose connect, and voil! it will work.
Note: Be aware of the following problems with the BDE Msaccess native
driver(which is actually just a wrapper to the DAO/JET engine).
1: DAO is not thread safe, so you should use your DB just from your
programs main thread.
2. As quick report is multi-threaded it doesnt work with the Native
MSAccess driver. so you should keep mantaining a separate ODBC connection
just to keep your Qreports working or use Digital Metaphors Report Builder
(BTW, a superb product).
3. MS Access is fine for a desktop applications, but if you go multiuser,
consider scaling to some SQL server as Interbase. MSAccess locks several
contiguos pages in a edit, and you could have some hard to troubleshoot
locking problems.
4. If you rely on autoinc fields, make sure you dont have default values
for any field in the same table, or the seed will go crazy over time...
good luck...
PS: if you move to interbase you will have a smoothier porting to linux with
kylix. Think about it! its unlikely there will ever be a MSAccess driver
for linux, as MS never published the specifications for the MDB file format.



Quote:
> Hi all

> I have a problem that no doubt has a simple solution, but before I get to
> that perhaps someone can clear things up for me. From what I have read
from
> various sources I have got the impression that it is possible to connect
to
> an Access DB without using the BDE or ODBC. This is to be accomplished via
a
> TDatabase component. Is this true?

> Whether this is true or not will no doubt affect my second question. Using
> the above idea I am trying to connect to a .mdb that is in the same
> directory as the program. The following properties have been set:

> DriverName = Microsoft Access Driver (*.mdb)//though I have tried MSACCESS
> LoginPrompt = False

> I set the DatabaseName to the name of the database like so,

> DatabaseName = db1.mdb

> The problem is that when I try to connect the database at run time it
gives
> the following error message
> "Invalid Parameter"

> Can anyone tell me where I am going wrong? The ideal solution that I would
> like to have is one where it is possible to simply cart the program and
the
> DB around where ever I want it, and not need to have to set up ODBC or
BDE.
> I would obviously needto take the DB support files with me as well.

> --
> ~~~~~~~~~~~~~
> ?raig ?eynolds
> ~~~~~~~~~~~~~
> Just becuase this is never going to work is no reason to be negative!



Wed, 15 Oct 2003 00:30:32 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Delphi components for MS Access 95/97/2000

2. Create ACCESS 2000 connection in code

3. QReport doesn't work when native connection to MS Access 97 is used

4. Delphi 3 connection to Access 97 database?

5. Access 2000 to SQL 2000

6. Access 2000 ODBC problems?

7. Problems with ACCESS 97 and empty strings

8. Problem with Access 97 & TDatabase

9. Problem reading paradox table in MS Access 97

10. Problems with delphi4 and Access 97

11. Delphi 4 + Access 97 - Installation problems

12. Access 97 SQL, escaping problem

 

 
Powered by phpBB® Forum Software