Solved

Using data base without specifying its absolute path

Posted on 2004-09-20
7
260 Views
Last Modified: 2010-04-05
1.) How I Can connect to an database without specifying the absolute path of data base file.
     I need this because I have data base and exe file in folder c:/MyProgram, and this program will not work on other people's computers because maybe they will not hold program on the same address (for example c:/Programs/MyProgram... or so).

2.) Is it ok to use M. Access data base when I work with 50 000 records?
0
Comment
Question by:UrosVidojevic
7 Comments
 
LVL 7

Author Comment

by:UrosVidojevic
ID: 12101708
information:

I am using ADO.
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12101850
if you have the Application and the DB in the same location just skip the path from the connectionstring leaving just the FileName (i.e. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb;Persist Security Info=False).
0
 
LVL 2

Expert Comment

by:gary_williams
ID: 12102056
Table.DatabaseName := ExtractFilePath(Application.EXEName) + 'mytable.db'
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 50 total points
ID: 12102487
Personally, I prefer to use an INI file in which I store the path of the database. This would allow you to put it anywhere you like. At the start of the application you could check if the file exists and if it doesn't, pop up a file dialog screen asking the user to enter where the database is located.
If you use the TADOConnection then by setting the path in the connectionstring should solve it quite easily. Simply use:
  ADOConnection1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ExtractFilePath(ParamStr(0)+'Database.mdb;Persist Security Info=False';

Now, using Access with 50.000 records should be okay. I've done worse. But it won't perform as fast. Using Oracle, InterBase or SQL Server would be faster. I do hope your system has a lot of memory, though. If you do a query that returns all those records, they will all be put in memory and if there's not enough memory the swapfile will be used. Not that this won't happen with other databases, though. But be aware that if you use large amounts of records then always try to keep your datasets as small as possible in some way.
Also be aware of transactions. Make sure they're committed or else again, memory problems...
0
 
LVL 7

Author Comment

by:UrosVidojevic
ID: 12103893
I have some problems with giving the points to Alex, because when I click accept it tells me Error

ERROR
Answer not found (ID: 11).

Do you know what's the problem?
0
 
LVL 45

Expert Comment

by:aikimark
ID: 12107826
I agree with Alex that you should retain the location of the MSAccess database between executions either in an INI file, XML config file, or in the Windows registry.  If the path is not known, allow the user to select the path, starting with the application directory.  Access can easily handle 50k rows.

If you have performance problems with your MSAccess database, look at the following as potential remedies:
* launch the JetComp.exe utility to repair and compact the database
* look at the queries you are executing.  There are often too few or too many indexes.
* also make sure that you execute as many stored queries as possible, converting your dynamic SQL into MSAccess querydefs.
* replace your MSAccess database with an MSDE database, which mimics a SQL Server.
* do some query optimization
   > retrieve only the columns you need
   > look for inefficiencies in your WHERE clause
   > look at your table join efficiencies
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now