Solved

Using data base without specifying its absolute path

Posted on 2004-09-20
7
262 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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