Solved

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

Posted on 2008-10-09
9
150 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

9 Experts available now in Live!

Get 1:1 Help Now