Solved

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

Posted on 2008-10-09
9
151 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

17 Experts available now in Live!

Get 1:1 Help Now