DBEXPRES组件。怎么在程序设计时。动态的连接数据库 使用EXPRESS组件,比如SQLCONNECTION时。怎么能让他动态的连接数据库。就使用ADO那样。当需要用那个数据库时。才连接! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //连接信息保存在ini文件中procedure Set_SQLConnection(SQLCon:TSQLConnection;DBName:string;const Alias:string='');var fini:TIniFile; se,s:string;begin SQLCon.Params.Clear ; SQLCon.DriverName :='MSSQL'; SQLCon.GetDriverFunc :='getSQLDriverMSSQL'; SQLCon.LibraryName :='dbxmss30.dll'; SQLCon.VendorLib :='oledb'; s:=ExtractFilePath(Paramstr(0))+'config.ini'; Fini:=TIniFile.Create(s); se:=DBName; With SQLCon.Params do begin add('DriverName=MSSQL'); add('HostName='+Fini.readstring(se,'host',''));//服务器 add('DataBase='+DBName); add('User_Name='+Fini.ReadString(se,'username',''));//登录用户名 add('Password='+Fini.ReadString(se,'password',''));//登录密码 add('BlobSize=0'); if Fini.ReadBool(se,'oslogin',False) then//是否为windows身份验证 add('OS Authentication=True') else add('OS Authentication=False'); add('Prepare SQL=True'); end; if Alias='' then//设置别名 SQLCon.ConnectionName :=DBName else SQLCon.ConnectionName :=Alias; SQLCon.LoginPrompt :=false;end; Delphi/Pascal中有break,continue和return语句吗? 急,关于数据库死锁的问题 delphi SQL语句的几个小问题 我在程序中用ado连接SQL SERVER数据库 问:在打包时候如何处理数据库别名 解决了问题,所有分都给你!!包括未来半年的!! ======十万火急,请问一个错误!======= TStingList问题,急!! 为什么Gis控件MapObject2.0在升级到delphi6.0后无法正常使用! 本人想在程序中集成开始菜单及桌面的快捷方式! 各位大哥怎样培养编程的兴趣呢?——白小姐 保存log 讨论一下:COM+中的全局变量
procedure Set_SQLConnection(SQLCon:TSQLConnection;DBName:string;const Alias:string='');
var
fini:TIniFile;
se,s:string;
begin
SQLCon.Params.Clear ;
SQLCon.DriverName :='MSSQL';
SQLCon.GetDriverFunc :='getSQLDriverMSSQL';
SQLCon.LibraryName :='dbxmss30.dll';
SQLCon.VendorLib :='oledb';
s:=ExtractFilePath(Paramstr(0))+'config.ini';
Fini:=TIniFile.Create(s);
se:=DBName;
With SQLCon.Params do
begin
add('DriverName=MSSQL');
add('HostName='+Fini.readstring(se,'host',''));//服务器
add('DataBase='+DBName);
add('User_Name='+Fini.ReadString(se,'username',''));//登录用户名
add('Password='+Fini.ReadString(se,'password',''));//登录密码
add('BlobSize=0');
if Fini.ReadBool(se,'oslogin',False) then//是否为windows身份验证
add('OS Authentication=True') else
add('OS Authentication=False');
add('Prepare SQL=True');
end;
if Alias='' then//设置别名
SQLCon.ConnectionName :=DBName else
SQLCon.ConnectionName :=Alias;
SQLCon.LoginPrompt :=false;
end;