begonz
asked on
Access / Delphi Password Problems.....
Hi experts,
When ever I try and set a password on the access DB my app is connecting to I get the following error:
-------------------------- -
Microsoft Data Link Error
-------------------------- -
Test connection failed because of an error in initializing provider. Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
-------------------------- -
OK
-------------------------- -
If any of you experts could please help me with this I would really appriciate your help and advise. What I want to do is then hard code the DB password and then have a table in the DB that contains user set username and password to actually log into the app.
I am connecting to the DB the following way:
************************** ********** ********** ********** ********** **
function GetDBLOCATION : String;
var
Reg : TRegistry;
begin
Result := '';
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey ('\Software\'+application. title, true) then
Result := Reg.ReadString ('DBNAME');
Reg.CloseKey;
finally
Reg.Free;
end;
end;
procedure TForm1.Startup(Sender: TObject);
var
Reg : TRegistry;
flag : Boolean;
begin
flag := True;
if Not DBConnected then
begin
DBPath := GetDBlocation;
while not FileExists(DBPath) do
begin
OpenDialog1.Title := 'Database Location';
OpenDialog1.Filter := 'Access Database|*.mdb';
if OpenDialog1.Execute then
begin
Reg := TRegistry.Create;
DBPath := OpenDialog1.FileName;
try
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey ('\Software\'+application. title, true); // Write path and address to register
Reg.CloseKey;
finally
Reg.Free;
end; // try
end // if
else
begin
showmessage('Unable to connect to the Database.');
flag:=false;
break;
end;
end;
if flag then
BankManagerConnection.Conn ectionStri ng := 'Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source='
+ DBPath
+ ';Persist Security Info=False';
DBConnected := True;
end;
end;
************************** ********** ********** ********** ********** **
What I want to do is:
1. App starts and creates a connection to the DB.
2. Form displayed user then inputs their details, if in table then login successful.
I need help with step 1.
Please help, desperate :o( Any questions please ask.
More points on offer for working solution.
Bego.
When ever I try and set a password on the access DB my app is connecting to I get the following error:
--------------------------
Microsoft Data Link Error
--------------------------
Test connection failed because of an error in initializing provider. Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
--------------------------
OK
--------------------------
If any of you experts could please help me with this I would really appriciate your help and advise. What I want to do is then hard code the DB password and then have a table in the DB that contains user set username and password to actually log into the app.
I am connecting to the DB the following way:
**************************
function GetDBLOCATION : String;
var
Reg : TRegistry;
begin
Result := '';
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey ('\Software\'+application.
Result := Reg.ReadString ('DBNAME');
Reg.CloseKey;
finally
Reg.Free;
end;
end;
procedure TForm1.Startup(Sender: TObject);
var
Reg : TRegistry;
flag : Boolean;
begin
flag := True;
if Not DBConnected then
begin
DBPath := GetDBlocation;
while not FileExists(DBPath) do
begin
OpenDialog1.Title := 'Database Location';
OpenDialog1.Filter := 'Access Database|*.mdb';
if OpenDialog1.Execute then
begin
Reg := TRegistry.Create;
DBPath := OpenDialog1.FileName;
try
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey ('\Software\'+application.
Reg.CloseKey;
finally
Reg.Free;
end; // try
end // if
else
begin
showmessage('Unable to connect to the Database.');
flag:=false;
break;
end;
end;
if flag then
BankManagerConnection.Conn
+ DBPath
+ ';Persist Security Info=False';
DBConnected := True;
end;
end;
**************************
What I want to do is:
1. App starts and creates a connection to the DB.
2. Form displayed user then inputs their details, if in table then login successful.
I need help with step 1.
Please help, desperate :o( Any questions please ask.
More points on offer for working solution.
Bego.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
add the password to the connection string and set Persist Security Info = True. also set Login Prompt = False
and make sure the database is not opened (is not in use)
and make sure the database is not opened (is not in use)
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey ('\Software\'+application. title, true); // Write path and address to register
Reg.CloseKey;
This is incorrect. You have to write to the registry useing WriteString. So it should be:
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey ('\Software\'+application. title, true); // Write path and address to register
Reg.WriteString(OpenDialog 1.FileName )
Reg.CloseKey;
Reg.OpenKey ('\Software\'+application.
Reg.CloseKey;
This is incorrect. You have to write to the registry useing WriteString. So it should be:
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey ('\Software\'+application.
Reg.WriteString(OpenDialog
Reg.CloseKey;
Then somewhere you need to set DBPath equal to OpenDialog1.FileName.
Hi
Just a comment.
I have seen this problem before with ADO but can't remember the reason (I use DAO with Access - it is lots faster and all the databound VB controls work with it - they dont with the ADO).
I suggest that you re-install the MDAC (2.7) followed by the Jet Engine (Jet40Sp3_Comp.exe).
I have just checked and the MDAC is now 2.8 - http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&displaylang=en
The Jet Engine is not included with the MDAC anymore, and looks like Microsoft are being a bit coy about giving it you now - you can dowload it from http://www.omegatron.nl/default.asp?target=download.asp
Voodooman
Just a comment.
I have seen this problem before with ADO but can't remember the reason (I use DAO with Access - it is lots faster and all the databound VB controls work with it - they dont with the ADO).
I suggest that you re-install the MDAC (2.7) followed by the Jet Engine (Jet40Sp3_Comp.exe).
I have just checked and the MDAC is now 2.8 - http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&displaylang=en
The Jet Engine is not included with the MDAC anymore, and looks like Microsoft are being a bit coy about giving it you now - you can dowload it from http://www.omegatron.nl/default.asp?target=download.asp
Voodooman
ASKER
Thanks Mohammed exactly what I wanted. Finally got it connected last night with only minor change to my existing code.
I have also managed to get my user login form working as well.
Thanks again.
Bego.
I have also managed to get my user login form working as well.
Thanks again.
Bego.
BankManagerConnection.Conn
:= 'Provider=Microsoft.Jet.OL
+ DBPath
+ 'Mode=ReadWrite|Share Deny None;'
+ 'Persist Security Info=False';