Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using data base without specifying its absolute path

Posted on 2004-09-20
7
Medium Priority
?
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Author Comment

by:UrosVidojevic
ID: 12101708
information:

I am using ADO.
0
 
LVL 23

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 200 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 46

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

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