做一个mis系统,因种种原因,连SQLSERVER数据库时混用了ado和bde。比如使用dblookupcombobox时,listsource与datasource的数据源是两个类型,或是在同一pas文件中有用ado的datasource,也有bde的。
完成之后,把数据模块里database和adoconnection的配置删了,重新做了一个ini文件,在程序中写注册表生成odbc数据源,通过读取ini文件设置database和adoconnection(想把该ini文件以及该应用程序的exe文件拷贝到另一台机器上(装了bde)进行测试),但是在有dblookupcombobox控件的界面上就会出现这样的问题:
1)该dblookupcombobox的listsource与datasource的数据源都是bde连接,该控件不能用。
2)该dblookupcombobox的listsource与datasource的数据源为bde和ado连接,该控件不仅不能用,还有错误信息,是说bde引擎的错误。
像这种情况,该如何处理?要是把所有的bde连接转成ado的,程序改起来比较头疼。要是把使用dblookupcombobox的地方改成普通的combobox再编程,也比较麻烦,而且现在不知道会不会还有其他控件不能用。
就是开发这个才接触delphi有一个月,笨鸟请各位高手一定耐心看完,给个方向,我也就不到400分,只要提问不受分的限制,就全散了。
完成之后,把数据模块里database和adoconnection的配置删了,重新做了一个ini文件,在程序中写注册表生成odbc数据源,通过读取ini文件设置database和adoconnection(想把该ini文件以及该应用程序的exe文件拷贝到另一台机器上(装了bde)进行测试),但是在有dblookupcombobox控件的界面上就会出现这样的问题:
1)该dblookupcombobox的listsource与datasource的数据源都是bde连接,该控件不能用。
2)该dblookupcombobox的listsource与datasource的数据源为bde和ado连接,该控件不仅不能用,还有错误信息,是说bde引擎的错误。
像这种情况,该如何处理?要是把所有的bde连接转成ado的,程序改起来比较头疼。要是把使用dblookupcombobox的地方改成普通的combobox再编程,也比较麻烦,而且现在不知道会不会还有其他控件不能用。
就是开发这个才接触delphi有一个月,笨鸟请各位高手一定耐心看完,给个方向,我也就不到400分,只要提问不受分的限制,就全散了。
dm_main.T_Mg.Close;
dm_main.T_Mg.Filtered:=false;
dm_main.T_Mg.Filter:='id='''+curnodename+'''';
dm_main.T_Mg.Filtered:=true;
Dm_main.T_Mg.Open;
运行时出现错误框:Project P_main.exe reaised exception class EDBEngineError with message 'Capability not supported.'……这里curnodename是一个string类型变量,保存treeview当前单击的节点的文本。而通过向导建立odbc数据源时,就不会有上面的问题。
我程序建立odbc数据源的代码如下(是Copy来的^-^),请帮我看看问题在哪里:
function TDM_main.CreateDSN(sDriName,sDsnName:string): boolean;
var
regTmp: TRegistry;
sTmp: String;
begin
Result:= True;
regTmp:= TRegistry.Create;
try
with regTmp do
begin
RootKey:= HKEY_LOCAL_MACHINE;
if openkey('software\ODBC\ODBCINST.INI\'+sDriName,false) then
begin
sTmp:= ReadString('driver');
if sTmp = '' then
begin
result:= false;
exit;
end;
end
else
begin
result:= false;
exit;
end;
CloseKey;
RootKey:= HKEY_CURRENT_USER;
if openkey('software\ODBC\ODBC.INI\ODBC Data Sources',True) then
begin
if not ValueExists(sDsnName) then WriteString(sDsnName,sDriName);
end
else
begin
result:= false;
exit;
end;
CloseKey;
if openkey('software\ODBC\ODBC.INI\'+sDsnName,True) then
begin
if not ValueExists('ServerName') then
writeString('ServerName','');
if not ValueExists('DataBase') then
writeString('DataBase','');
if not ValueExists('UserName') then
writeString('UserName','');
if not ValueExists('Password') then
writeString('Password','');
if not ValueExists('Description') then
writeString('Description','DoWhat Create');
if not ValueExists('driver') then
writeString('driver',sTmp);
end
else
begin
result:= false;
exit;
end;
end;
finally
regTmp.CloseKey;
end;
end;
请问通过程序应该如何建立odbc数据源,上面的方法好不好?怎样解决我出现的问题?