Aquadp
asked on
why i can't use ADO to open DBF file in WIN-XP?
My Code:
...
function TDMCenter.OpenDBFDatabaseF ile(FilePa th,
FileName,Conditions: String): Boolean;
begin
Result := True;
try
qryDBFdest.Close;
qryDBFdest.ConnectionStrin g:='Provid er=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
...
function TDMCenter.OpenDBFDatabaseF
FileName,Conditions: String): Boolean;
begin
Result := True;
try
qryDBFdest.Close;
qryDBFdest.ConnectionStrin
+'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
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
Shouldn't it be FilePath + "\" + FileName?
oops.
"\\"
"\\"
Ok. Maybe not.
Have you checked the path and file exist?
Have you checked the path and file exist?
Does it work if you put a query on a form and use the wizard to set the connection string?
Do you have the right permissions to read/write the file in XP?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i sure the path is exist.
i call the function code:
my dbf file path:C:\dbf\mytable.dbf
OpenDBFDatabaseFile('C:\db f\','mytab le','');
i used ADOQuery.i have another test application(.exe) that can open dbf file in XP.
so i think my code is fault.
i call the function code:
my dbf file path:C:\dbf\mytable.dbf
OpenDBFDatabaseFile('C:\db
i used ADOQuery.i have another test application(.exe) that can open dbf file in XP.
so i think my code is fault.
perhaps it should be mytable.dbf instead?
ASKER
no ,it couldn't be mytable.dbf.
experts, please help me.
experts, please help me.
Try:
qryDBFdest.SQL.Add('SELECT * FROM '+FileName+' '+Conditions);
Perhaps the space is missing?
qryDBFdest.SQL.Add('SELECT
Perhaps the space is missing?
ASKER
i said,my program run in win2000 is ok,but run in winxp show error.
i think i should modify code below:
qryDBFdest.ConnectionStrin g:='Provid er=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 )
i think i should modify code below:
qryDBFdest.ConnectionStrin
+'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 )
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?
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?
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=;Sourc eDB=d:\;So urceType=D BF;Exclusi ve=No;Back groundFetc h=Yes;Coll ate=Machin e;Null=Yes ;Deleted=Y es;"
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...
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
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...
ASKER
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.
i changed my code into yours."Extended Properties="DSN=Visual FoxPro-database;"
but i try it and result is false.