why i can't use ADO to open DBF file in WIN-XP?

My Code:
...
function TDMCenter.OpenDBFDatabaseFile(FilePath,
  FileName,Conditions: String): Boolean;
begin
  Result := True;
  try
    qryDBFdest.Close;
    qryDBFdest.ConnectionString:='Provider=MSDASQL.1;'
                                +'Persist Security Info=False;'
                                +'Extended Properties='
                                +'"Driver={Microsoft Visual FoxPro Driver};'
                                +'UID=;'
                                +'SourceDB='+ FilePath + ';'
                                +'SourceType=DBF;'
                                +'Exclusive=No;'
                                +'BackgroundFetch=Yes;'
                                +'Collate=Machine;'
                                +'Null=Yes;'
                                +'Deleted=Yes;"';  
    qryDBFdest.SQL.Clear;
    qryDBFdest.SQL.Add('SELECT * FROM '+FileName+Conditions);
    qryDBFdest.Open;
  except
    Result := False;
  end;
end;
...

when my application run in WIN2000 no error,but in WIN-XP,the application always show error that couldn't open the DBF file.

why????:(how to modify my code.please help me
AquadpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

andrewjbCommented:
Shouldn't it be FilePath + "\" + FileName?

0
andrewjbCommented:
oops.

"\\"
0
andrewjbCommented:
Ok. Maybe not.

Have you checked the path and file exist?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

andrewjbCommented:
Does it work if you put a query on a form and use the wizard to set the connection string?
0
andrewjbCommented:
Do you have the right permissions to read/write the file in XP?
0
Wim ten BrinkSelf-employed developerCommented:
Have you installed the ODBC driver for FoxPro on the XP system? Is FoxPro even available on it?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AquadpAuthor Commented:
i sure the path is exist.

i call the function code:
my dbf file path:C:\dbf\mytable.dbf

OpenDBFDatabaseFile('C:\dbf\','mytable','');

i used ADOQuery.i have another test application(.exe) that can open dbf file in XP.
so i think my code is fault.
0
DragonSlayerCommented:
perhaps it should be mytable.dbf instead?
0
AquadpAuthor Commented:
no ,it couldn't be mytable.dbf.

experts, please help me.
0
Wim ten BrinkSelf-employed developerCommented:
Try:
  qryDBFdest.SQL.Add('SELECT * FROM '+FileName+' '+Conditions);
Perhaps the space is missing?
0
AquadpAuthor Commented:
i said,my program run in win2000 is ok,but run in winxp show error.

i think i should modify code below:
    qryDBFdest.ConnectionString:='Provider=MSDASQL.1;'
                                +'Persist Security Info=False;'
                                +'Extended Properties='
                                +'"Driver={Microsoft Visual FoxPro Driver};'
                                +'UID=;'
                                +'SourceDB='+ FilePath + ';'
                                +'SourceType=DBF;'
                                +'Exclusive=No;'
                                +'BackgroundFetch=Yes;'
                                +'Collate=Machine;'
                                +'Null=Yes;'
                                +'Deleted=Yes;"';

but i dont know where i should modify?(perhaps ODBC ,db driver or other drivers's error )
0
andrewjbCommented:
Could I ask again...
Does it work if you put a query on a form and use the wizard to set the connection string?

i.e. where did this connection string come from?
0
Wim ten BrinkSelf-employed developerCommented:
On your XP system, go to "Settings/Control panel/Administrative tools/ Data sources (ODBC)" and check for the existance of the "Microsoft Visual FoxPro Driver". Just to make sure it's there...

Now, on my W2K system, I made an ADO connection to some folder with the connection wizard and I get the following connection string:
  Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=Visual FoxPro-database;UID=;SourceDB=d:\;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"

Apparantly, I don't get one with the "Driver=Microsoft Visual FoxPro Driver}" that you seem to get. At least, this confuses me a bit...
0
AquadpAuthor Commented:
i checked that "Microsoft Visual FoxPro Driver" exists on my xp system.

i changed my code into yours."Extended Properties="DSN=Visual FoxPro-database;"
but i try it and result is false.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.