Solved

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

Posted on 2008-10-09
9
154 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
Technology Partners: 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

680 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