?
Solved

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

Posted on 2008-10-09
9
Medium Priority
?
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 13

Accepted Solution

by:
rfwoolf earned 1000 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
Independent Software Vendors: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

718 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