B
babysheep
Unregistered / Unconfirmed
GUEST, unregistred user!
我想自动配置foxpro引擎的odbc,程序运行成功,但是看odbc数据源时总说:找不到驱动。
为什么?
以下是程序(以前是用在sqlserver上面的,可能改错了什么地方):
implementation
uses datamodule,Registry;
{$R *.DFM}
function TFORM_STARTZL.RegistryAnyWhere(StrDsn:string):boolean;
var
registerTemp : TRegistry;
StrOdbcIni:string;
begin
StrOdbcIni:='Software/ODBC/ODBC.INI/';
registerTemp := TRegistry.Create; //建立一个Registry实例
with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey(StrOdbcIni+'ODBC Data Sources',True) then
DeleteValue( StrDsn );
CloseKey;
if KeyExists(StrOdbcIni+StrDsn) then
DeleteKey(StrOdbcIni+StrDsn);
RootKey:=HKEY_CURRENT_USER;
if OpenKey(StrOdbcIni+'ODBC Data Sources',True) then
begin
WriteString( StrDsn, 'Microsoft FoxPro VFP Driver ' );
end
else
begin
MessageDlg('增加ODBC数据源失败:'+StrDsn, mtError, [mbOK] ,0);
result:=false;
exit;
end;
CloseKey;
//<<找到或创建System DSN Configuration Information
if KeyExists(StrOdbcIni+StrDsn) then
DeleteKey(StrOdbcIni+StrDsn);
if OpenKey(StrOdbcIni+StrDsn,True) then
begin
WriteString( 'DataBase Type', 'Free table directory' );
WriteString( 'Driver', 'C:/WINNT/System32/vfpodbc.dll' );
Writestring( 'path', 'D:/' );
end
else
begin
MessageDlg('增加ODBC数据源失败:'+StrDsn, mtError, [mbOK] ,0);
result:=false;
exit;
end;
CloseKey;
Free;
result:=true;
end;
end;
为什么?
以下是程序(以前是用在sqlserver上面的,可能改错了什么地方):
implementation
uses datamodule,Registry;
{$R *.DFM}
function TFORM_STARTZL.RegistryAnyWhere(StrDsn:string):boolean;
var
registerTemp : TRegistry;
StrOdbcIni:string;
begin
StrOdbcIni:='Software/ODBC/ODBC.INI/';
registerTemp := TRegistry.Create; //建立一个Registry实例
with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey(StrOdbcIni+'ODBC Data Sources',True) then
DeleteValue( StrDsn );
CloseKey;
if KeyExists(StrOdbcIni+StrDsn) then
DeleteKey(StrOdbcIni+StrDsn);
RootKey:=HKEY_CURRENT_USER;
if OpenKey(StrOdbcIni+'ODBC Data Sources',True) then
begin
WriteString( StrDsn, 'Microsoft FoxPro VFP Driver ' );
end
else
begin
MessageDlg('增加ODBC数据源失败:'+StrDsn, mtError, [mbOK] ,0);
result:=false;
exit;
end;
CloseKey;
//<<找到或创建System DSN Configuration Information
if KeyExists(StrOdbcIni+StrDsn) then
DeleteKey(StrOdbcIni+StrDsn);
if OpenKey(StrOdbcIni+StrDsn,True) then
begin
WriteString( 'DataBase Type', 'Free table directory' );
WriteString( 'Driver', 'C:/WINNT/System32/vfpodbc.dll' );
Writestring( 'path', 'D:/' );
end
else
begin
MessageDlg('增加ODBC数据源失败:'+StrDsn, mtError, [mbOK] ,0);
result:=false;
exit;
end;
CloseKey;
Free;
result:=true;
end;
end;