Solved

I need a help with my program and my database in access

Posted on 2008-10-09
9
152 Views
Last Modified: 2010-04-21
Hello Guys

I am having problem with a application that uses as database access, my program works with 4 databases and one of them has some linked table from another database. I have to change the name of the folder where the databases are kept. After doing this, I had a problem to open my linked tables in access. Access complains that the path is wrong.

How could I fix this? The database were in my c:\carsystem\database and now they were placed in the server, the path that I uses to access the databases is \\10.10.1.2\carsystem\database,

I made an example of system using a small access database so that you could see the problem that I am facing. You can download it from this link www.infosoftlanguages.com/arquivos/AccessTest.zip

After installing it in c:\  change the folder name database to database2, don't forget to change the path in the event beforeconnection of adoconnection to database2, open the queries, you will see the problem.

my question is:
 is there any way to pass the path of my folder so that the access doesn't keep a fix path?


thankls
0
Comment
Question by:hidrau
  • 5
  • 3
9 Comments
 
LVL 13

Accepted Solution

by:
rfwoolf earned 500 total points
ID: 22677699
How are you connecting from your application to the access database? are you using an ADOConnection for example? In any case you usually connect using a Connection string -- which you can build at DESIGN TIME using the TADOTable or TADOConnection by clicking on the "Connection String" property in the object inspector.
All you need to do is put the correct path to the database(s) inside your connection string.
Because the path to the database might change depending on where you install your software, it's good to store this piece of information outside of your program using an INIfile.
something like
uses
INIFiles;
var
 myINIfile : TINIFile;
MyDatabasePath : string;
begin
//create the INI file (if it doesn't already exist). Here I use the ApplicationDataFolder
//of the system which is good for Vista compatibility.
    myINI := TINIFile.Create(GetApplicationDataFolder + '\lclsettings.ini');

//To READ string in this example you do this
  MyDatabasePath := myINI.ReadString('LoadSettings', 'DatabasePath', 'undefined');
(the last part, 'undefined' is what is returned if there is no value there, for example the very first time you do this. If there is a value, then the actual path will be returned).
To WRITE string is this example:
  myINI.WriteString('LoadSettings', 'FileDir', Edit1.Text);
You can then be quite creative and say this:
IF MyINI.ReadString('LoadSettings', 'DatabasePath', 'undefined') = 'undefined' THEN
showmessage('You have not defined a path to your database, idiot');
//and then bring up an input to ask the user for the path - like a TOpenDialog
 
So ultimately you will say something like this
MyADOConnection.ConnectionString := 'BLAH BLAH BLAH BLAH BLAH; BLAH; BLAH BLAH; Path=' + MyINI.Readstring('LoadSettings', 'DAtabasePath', 'undefined');
MyADOConnection.Connected := true;
 
I hope this helps
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 22677704
There is a tutorial on delphi and INI files at about.com and elsewhere on the net
0
 
LVL 1

Author Comment

by:hidrau
ID: 22677758
rfwoolf: you didn't understand my problem,

this I know to do perfect . The problem is the linked table inside of base1 , please download de example I assembled in Delphi 7 and do what I am telling, you will see the problem

0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 13

Expert Comment

by:rfwoolf
ID: 22677781
Oh I see. So this doesn't really have anything to do with Delphi? This sounds more like an Access problem. You have 2 databases in Access and the 1 database is linked to the other. When the path/location of the 2nd database changes, the 1st databaes can't find it?
I'm not sure about that one. In that case you should add your question to the MS Access zone
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 22677860
To update your linked tables I think you need to open access then go to the tools menu, add-ins, linked table manager. Here you should be able to update where your linked tables get their information from.
Hope this is what you are looking for Hidrau.
0
 
LVL 1

Author Comment

by:hidrau
ID: 22677869
Yeah, this is my problem

I wonder if there any command that I could fix it or if someone has already passed by this problem.
I am trying to find the solution :( and not yet
0
 
LVL 1

Author Comment

by:hidrau
ID: 22677930
mikelittlewood: do you know if there is any command that I could do throgh my system running in a adoquery?
0
 
LVL 1

Author Comment

by:hidrau
ID: 22678393
Everybody here knows how could I run this function in access through delphi?
http://www.mvps.org/access/tables/tbl0009.htm

This will reflesh all linked tables
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 31504610
It wasn't what I was looking for, but that answer gave me another ideia
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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