?
Solved

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

Posted on 2004-11-19
14
Medium Priority
?
179 Views
Last Modified: 2010-04-05
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
0
Comment
Question by:Aquadp
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 12

Expert Comment

by:andrewjb
ID: 12624421
Shouldn't it be FilePath + "\" + FileName?

0
 
LVL 12

Expert Comment

by:andrewjb
ID: 12624428
oops.

"\\"
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 12624434
Ok. Maybe not.

Have you checked the path and file exist?
0
Technology Partners: 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 12

Expert Comment

by:andrewjb
ID: 12624441
Does it work if you put a query on a form and use the wizard to set the connection string?
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 12624445
Do you have the right permissions to read/write the file in XP?
0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 300 total points
ID: 12624800
Have you installed the ODBC driver for FoxPro on the XP system? Is FoxPro even available on it?
0
 

Author Comment

by:Aquadp
ID: 12631872
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
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12632262
perhaps it should be mytable.dbf instead?
0
 

Author Comment

by:Aquadp
ID: 12640921
no ,it couldn't be mytable.dbf.

experts, please help me.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12645291
Try:
  qryDBFdest.SQL.Add('SELECT * FROM '+FileName+' '+Conditions);
Perhaps the space is missing?
0
 

Author Comment

by:Aquadp
ID: 12651236
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
 
LVL 12

Expert Comment

by:andrewjb
ID: 12652796
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
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12664084
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
 

Author Comment

by:Aquadp
ID: 12678138
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 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