我想将ADOCONNECTION的连接字符串写入到INI文件中,再在程序中读取字符串进行数据库的连接
请问具体代码如何?
请问具体代码如何?
解决方案 »
- API sendMessage
- 你们好啊!如何我把listbox中的每条记录 在我创建的sql数据库中查找到 并输出sql中的和这条记录相关的其他字段到另一个listbox中
- 【发布软件兼散分,无需注册,欢迎拷贝,欢迎盗版 -- 续之公布原码】
- 有关查询的问题,新手请教!!!
- 怎样运用Delphi编写Windows 2000中的服务程序
- 问一个有关ComboBox的问题
- 有关数据库.
- 如何使用API修改ComboBox的style属性csDropDownList为csDropDown?
- 紧急求救~~~
- 用Dephi作cgi,前台提交的method="get"正常,post时就要我下载cgi程序,cgi内容s:=request.QueryFields.Strings[0]
- 我要用一个字符串变量(代表窗体名) 打开窗体
- valuelisteditor控件在那个块里?
inifile.readstring(程序,项目,值);
inifile.writestring(程序,项目,值);
用上面的方法将你的参数写到INI文件中就可以了。
delphi帮助上有ini文件的操作
function tdmodule.getstr():string;
var path:String;
tmp:TStrings;
counter:Integer;
myIniFile:Tinifile;//配置文件
begin
tmp:=TStringList.Create;
try
path:=ExtractFilePath(Application.Exename);
myIniFile:=TiniFile.Create(path+'database.ini');
myIniFile.ReadSectionValues('database',tmp);
Result:=' ';
for counter:=0 to tmp.Count-1 do
Result:=Result+tmp.Strings[counter];
finally
tmp.Free;
end;
end;
//连接数据库
function tdmodule.connectedDB(var msg:string):boolean;
begin
if ADOConnection1.Connected then
Result:=True
else
begin
try
ADOConnection1.ConnectionString:=getStr;
adoconnection1.LoginPrompt:=false;
adoquery1.Connection:=ADOConnection1;
if length(trim(ADOConnection1.ConnectionString))=0 then
begin
msg:='错误的连接字符串!';
Result:=False;
end
else
begin
ADOConnection1.Connected:=True;
Result:=True;
end;
except
msg:='无法建立数据库连接!';
Result:=False;
end;
end;
end;