Hello,
I tried it nearly as you said.
I determined with shfolder and constant CSIDL_COMMON_Documents the folder where my databases should be needed. I copied the databases mdb in this folder. Then I construct with the same path string the connectionstring.
At design conditions it worked (winxP Pro). But when I tried to install it on another computer with winXP home, it didn't.
During installation I got a message: 'C:\Program files\TED\DBFiles\thereda.mdb' not found !!!
(where "TED" is the application directory, "DBfiles" a directory that I used before but even not in this compiled Innoset up script and only in the original delphi code, and "thereda.mdb" the database)
Where, except in the string, it is written where to search for the database ?
Might it be in the ACCESS File (options/General ?: I changed it but it did not change anything)
So last time it was in "Document and Settings" now it searches in "Program files/TED/DBFiles/", a folder which does not exist .... I had this problem before... seems that the constant is not constantly the same ???
When I used winXP pro, fiels are copied in "Document and settings/all users", under windows XP home they are copied in "Document and settings/all users/shared documents"
And the program searches nearly each time I change something / the system at another place, even not in the special folder.
Where is it specified ? I have to read out this path and/ or create my own folder. How can I create a folder by the way in Delphi?
This letter action would also be interesting if it is possible to evaluate the error "database" not found with the path. Best would probably extract the path from the windows message and copy files to this place. How can I do this ?
I also found the problem that the
Thanks very much.
Thomas Willms
PS: I would nearly like to create a simplified extra version of my program to you to get rid of this problem .... and send it by mail. The code I used is :
function GetFolder(ID: Cardinal; Create: Boolean): string;
var Res: HResult;
Path: array[0..Max_Path] of Char;
const
shgfp_Type_Current: cardinal = $0;
begin
if Create then ID := ID or csidl_Flag_Create;
Res := ShGetFolderPath(0, ID, 0, shgfp_Type_Current, @Path[0]);
Result := Path ; /// '\MyFolder\'Welcher Name ist das ?
if S_OK <> Res then
raise Exception.Create('Could not determine folder path');
end;
procedure mdbfilelocation(verzE,WRITEpATH1 : STRING);
var filesource,filedest : string;
begin
fileSource := verze + '\Thereda.mdb';fileDest := WritePath1 +'\'+ 'Thereda.mdb';
CopyFile(PChar(fileSource), PChar(fileDest), False);
//try DeleteFile(fileSource); finally end;
fileSource := verze + '\Theredaprivate.mdb';fileDest := WritePath1 +'\'+ 'Theredaprivate.mdb';
CopyFile(PChar(fileSource), PChar(fileDest), False);
//try DeleteFile(fileSource); finally end;
fileSource := verze + '\KopieTheredapriv.mdb';fileDest := WritePath1 + '\'+ 'KopieTheredapriv.mdb';
CopyFile(PChar(fileSource), PChar(fileDest), False);
//try DeleteFile(fileSource); finally end;
end;
procedure ADOConnectTest(cst1,cst2,cst3 : widestring;resultC : boolean);
begin
resultC :=true;
try Form1.adoConnection1.connected := false;Form1.adoConnection1.connectionstring := cst1;
Form1.adoConnection1.connected :=true;
Form1.ADOConnection2.GetTableNames(Form1.ListBox3.Items, False);
Form1.adoConnection2.connected := false;Form1.adoConnection2.connectionstring := cst2;
Form1.adoConnection2.connected :=true; Form1.adoConnection3.connected := false;
Form1.adoConnection3.connectionstring := cst3;
Form1.adoConnection3.connected :=true;
except resultC :=false; end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var Dateiname,error1,m ,w,writepath,filesource,filedest : string; cs1,cs2,cs3: widestring;
option1,i,Feldnamenzahl : integer;ok : boolean;
begin
Sendergruppe := 'Nichts'; IDZahl:=0; IDAnfang:=0;
TabbedNB1.PageIndex := 0; Listbox2.Items.Clear;Listbox3.Items.Clear;
verz := extractFilepath(ParamStr(0));Form1.ListBox3.Clear;
WritePath := GetFolder( CSIDL_COMMON_DOCUMENTS, True);
mdbfilelocation(verz,WRITEpATH);
cs1 := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+
writepath + '\Thereda.mdb;Mode=ReadWrite;Extended Properties="";Persist Security Info=False';
cs2 := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+
writepath + '\Theredaprivate.mdb;Mode=ReadWrite;Extended Properties="";Persist Security Info=False';
cs3 := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+
writepath + '\KopieTheredapriv.mdb;Mode=ReadWrite;Extended Properties="";Persist Security Info=False';
//Showmessage('Bitte notieren Sie sich das folgende Verzeichnis in dem die Thereda-Datenbankdateien gesucht werden !');
ADOConnectTest(cs1,cs2,cs3,ok);
if OK = true then
begin
Showmessage('Die Thereda-Datenbankdateien befinden sich in: ' + writepath);
end //WritePath := '.\Theredaprivate.mdb'; //Showmessage('Die Thereda-Datenbankdateien befinden sich in: ' + writepath);
else begin
//writepath := inputbox('Geben Sie den notierten Pfad ein: ','Datenbank','');
mdbfilelocation(verz,WRITEpATH);
cs1 := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+
writepath + '\Thereda.mdb;Mode=ReadWrite;Extended Properties="";Persist Security Info=False';
cs2 := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+
writepath + '\Theredaprivate.mdb;Mode=ReadWrite;Extended Properties="";Persist Security Info=False';
cs3 := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+
writepath + '\KopieTheredapriv.mdb;Mode=ReadWrite;Extended Properties="";Persist Security Info=False';
ADOConnectTest(cs1,cs2,cs3,ok);
end;
end;
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[Setup]
AppName=TED
AppVerName=TED1.0
AppPublisher=GRS, Inc.
AppPublisherURL=http://www.thereda.de
AppSupportURL=http://www.thereda.de
AppUpdatesURL=http://www.thereda.de
DefaultDirName={pf}\TED
DefaultGroupName=TED
OutputDir=G:\compiled\TEDEXE\exe
OutputBaseFilename=setup
Compression=lzma
SolidCompression=true
DirExistsWarning=yes
[Languages]
Name: english; MessagesFile: compiler:Default.isl
Name: french; MessagesFile: compiler:Languages\French.isl
Name: german; MessagesFile: compiler:Languages\German.isl
[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
[Files]
Source: TED1local\Project1.exe; DestDir: {app}; Flags: ignoreversion
Source: TED1local\KopieTheredaPriv.mdb; DestDir: {app}; Flags: ignoreversion
Source: TED1local\Thereda.mdb; DestDir: {app}; Flags: ignoreversion
Source: TED1local\TheredaPrivate.mdb; DestDir: {app}; Flags: ignoreversion
Source: files\rtl90.bpl; DestDir: {app}; Flags: ignoreversion
Source: files\adortl90.bpl; DestDir: {app}; Flags: ignoreversion
Source: files\dbrtl90.bpl; DestDir: {app}; Flags: ignoreversion
Source: files\bdertl90.bpl; DestDir: {app}; Flags: ignoreversion
Source: files\vcl90.bpl; DestDir: {app}; Flags: ignoreversion
Source: files\vcldb90.bpl; DestDir: {app}; Flags: ignoreversion
Source: files\vclx90.bpl; DestDir: {app}; Flags: ignoreversion
;Source: files\vclib90.bpl; DestDir: {app}; Flags: ignoreversion
Source: files\vcljpg90.bpl; DestDir: {app}; Flags: ignoreversion
Source: files\tmsd2005.bdsgroup; DestDir: {app}; Flags: ignoreversion
Source: files\tmsded2005.bdsproj; DestDir: {app}; Flags: ignoreversion
Source: TED1local\TOLOAD\aqPhase1.dat; DestDir: {app}\TOLOAD\; Flags: ignoreversion
Source: TED1local\TOLOAD\Phase1.dat; DestDir: {app}\TOLOAD\; Flags: ignoreversion
Source: TED1local\TheredaADO.dsn; DestDir: {app}; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: {group}\TED; Filename: {app}\Project1.exe
Name: {group}\{cm:UninstallProgram,TED}; Filename: {uninstallexe}
Name: {commondesktop}\TED; Filename: {app}\Project1.exe; Tasks: desktopicon
[Run]
Filename: {app}\Project1.exe; Description: {cm:LaunchProgram,TED}; Flags: nowait postinstall skipifsilent
[_ISTool]
UseAbsolutePaths=true
Post by MikeRPost by Thomas WillmsThe problem is that the path of the databank in my application is the same as for the application, so databank operations which are essential are not possible.
I would not really like to put my files there. But, when I accept it how must I write the line ? Like this ?
Source: TRechner-Test5\tabellen.mdb; DestDir: {userappdata}; Flags: ignoreversion
Yes.
Post by Thomas WillmsBefore I copied the mdb files to {app}
That is were is pointing the connectionstring.
If it is not in {app} how construct the connectionstring ???
I cannot put "C:\document and settings\user"
in the connection string. It might be D: or else.
also, it might be a frensh or german version of windows....
I do it this way. WritePath is a string property.
Add shfolder to your uses clause. Look in the shfolder unit for all the constants like CSIDL_COMMON_APPDATA.
WritePath := GetFolder(CSIDL_COMMON_APPDATA, True);
function TfrmMyApp.GetFolder(ID: Cardinal; Create: Boolean): string;
var Res: HResult;
Path: array[0..Max_Path] of Char;
const
shgfp_Type_Current: cardinal = $0;
begin
if Create then ID := ID or csidl_Flag_Create;
Result := Path + '\MyFolder\';
if S_OK <> Res then
raise Exception.Create('Could not determine folder path');
end;