系统运行后,如何用ADO自动连接到数据库? 已设计好一个数据库连接与配置模块. 当客户端程序想登陆到另一台服务器数据库时,用该模块进行登陆.但是登陆后,程序如何自动获得该数据库配置信息(注:不用Ini文件.)? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你段程序 自己看function TDBDataModule.ConnectServer():boolean;var strCnn: string;begin Result := false; //设处置为连接不成功 strCnn := GetSetting(Application.Title,'database','数据库连接');//读注册表 if strCnn='' then begin try //为空则提供连接向导 strCnn:=(Datalinks.PromptNew() as _Connection).connectionstring;//转换接口 except exit; //取消连接向导则退出应用程序 end; Savesetting(Application.Title,'database','数据库连接',strCnn);//存注册表 //Savesetting(Application.Title,'database','login',EnDeCode(password));//存注册表 end; ADOCnn.ConnectionString :=strCnn; try //试着打开连接 //AdoCnn.open(username,password); ADOCnn.Connected := true; Result := true; //连接成功 except //if ReConnectServer()=1 then begin //不成功则在原连接信息基础上再次给出连接向导 // Result:=true; //end; Result := false; end;end; up运行该语句:"Savesetting(Application.Title,'database','数据库连接',strCnn);//存注册表"时提示出错:[Error] AdoConn.pas(188): Undeclared identifier: 'Savesetting'. 没想到delphi DBXXXX居然这样子得到recordCount 如何跟踪调试动态库? 请各位大侠帮忙看看,为什么同一个存储过程分别用BDE和ADO连,执行结果却不一样? ADOQuery的参数应该怎么赋?????????? 老话体 -> 需一从Excell转Access的通用程序 关于动态创建与释放的问题 小数位数问题! 请问斑竹,如何提高可用分? 不知道怎么提取分笔成交数据,有更好的接口吗? 大家帮忙看看,socket通信的问题, DBEdit的空格烦恼 一个DBQuery的问题!
var
strCnn: string;
begin
Result := false; //设处置为连接不成功
strCnn := GetSetting(Application.Title,'database','数据库连接');//读注册表
if strCnn='' then begin
try //为空则提供连接向导
strCnn:=(Datalinks.PromptNew() as _Connection).connectionstring;//转换接口
except
exit; //取消连接向导则退出应用程序
end;
Savesetting(Application.Title,'database','数据库连接',strCnn);//存注册表
//Savesetting(Application.Title,'database','login',EnDeCode(password));//存注册表
end;
ADOCnn.ConnectionString :=strCnn; try //试着打开连接
//AdoCnn.open(username,password);
ADOCnn.Connected := true;
Result := true; //连接成功
except
//if ReConnectServer()=1 then begin //不成功则在原连接信息基础上再次给出连接向导
// Result:=true;
//end;
Result := false;
end;
end;
运行该语句:
"Savesetting(Application.Title,'database','数据库连接',strCnn);//存注册表"时
提示出错:
[Error] AdoConn.pas(188): Undeclared identifier: 'Savesetting'.