将DELPHI数据库连接写进INI配置文件中
来源:互联网 发布:淘宝电费 编辑:程序博客网 时间:2024/04/30 08:37
DataBase.pas
++++++++++++++++++++++++++++++++++++++++++++
procedure TDM.DataModuleCreate(Sender: TObject);
var piececonfg:Tinifile;
pathconfgstr,Providerstr,UserIDstr,
Passwordstr,DataSourceStr,DatabaseNamestr :string;
begin
pathconfgstr:= ExtractFilePath(Application.ExeName);
if pathconfgstr[length(pathconfgstr)]='/' then
begin
pathconfgstr:=pathconfgstr+'piececonfg.ini';
piececonfg:=Tinifile.Create(pathconfgstr);
end
else
begin
pathconfgstr:=pathconfgstr+'/piececonfg.ini';
piececonfg:=Tinifile.Create(pathconfgstr);
end;
if not FileExists(pathconfgstr) then
begin
application.MessageBox('配置文件不存在!','提示',mb_ok);
application.Terminate;
end;
Providerstr:=piececonfg.ReadString('DataBaseConfig','Provider','');
UserIDstr:=piececonfg.ReadString('DataBaseConfig','UserID','');
Passwordstr:=piececonfg.ReadString('DataBaseConfig','Password','');
DataSourceStr:=piececonfg.ReadString('DataBaseConfig','DataSource','');
DatabaseNamestr:=piececonfg.ReadString('DataBaseConfig','DatabaseName','');
if (Providerstr='') or (DataSourceStr='') or (DatabaseNamestr='') then
begin
application.MessageBox('数据库配置不正确,请重新配置!','提示',mb_ok);
Application.Terminate;
end;
adoconn.Close;
adoconn.ConnectionString:='';
adoconn.ConnectionString:='Provider='+Providerstr+';UserID='+UserIDstr+';
Password='+Passwordstr+';Data Source='+DataSourceStr+
Initial Catalog='+DatabaseNamestr;
try
adoconn.Connected:=true;
except
application.MessageBox('数据库配置不正确,请重新配置!','提示',mb_ok);
adoconn.Connected:=false;
application.Terminate;
end;
search:=TstringList.create;
end;
piececonfg.ini
++++++++++++++++++++++++++++++++++++++++++++
[DataBaseConfig]
Provider=SQLOLEDB.1
UserID=sa
Password=sa
DataSource=192.168.1.1
DatabaseName=mjj
- 将DELPHI数据库连接写进INI配置文件中
- delphi 中配置文件的使用(*.ini)
- Delphi中读写INI配置文件操作总结
- delphi中ini配置文件(Inifile)使用方法
- delphi中写配置文件程序
- delphi读取.ini配置文件
- 写INI配置文件
- Delphi向Ini文件中写入流数据
- 在Delphi中实现将Font.Style写入INI文件
- 在Delphi中实现将Font.Style写入INI文件
- 如何将黑莓程序配置文件导出到INI中
- 【Qt 】QSettings写ini配置文件
- ado.net将数据库连接字符串放入配置文件中
- 如何将数据库连接字符串保存在配置文件中并读取
- Delphi TIniFile 类 操作ini配置文件
- Delphi TIniFile 类 操作ini配置文件
- Delphi TIniFile 类 操作ini配置文件
- Delphi TIniFile 类 操作ini配置文件
- 查看Linux版本命令
- 简单json对象for asp
- 常见内存故障分析!!
- Window.Open() 和 window.showModalDialog()参数
- java的Collection和Map
- 将DELPHI数据库连接写进INI配置文件中
- 各类语言对文件的操作
- sbo中怎么不通过linkbutton跳出来指定的应付发票
- 电脑维修的基本方法!!
- python_文件与目录操作
- 关于wince telnet组件的一篇博客
- 解决href使用onclick方法时点击该链接的时候不会跳转页面.但是滚动条会往上滚的问题
- asp.net留言本(文本格式)
- 异构数据库之间的复制(SQL)