如何动态指定数据源和数据库?(50分)

H

hongsen

Unregistered / Unconfirmed
GUEST, unregistred user!
在用MIDAS开发三层应用时,应该在何时从配置文件中读取数据源信息给
TADOConnection.ConnectionString?我不想在开发时将ConnectionString写死。
 
我想可以在连接之前设置吧,
可以加一个memo,visible := false,
利用他的saveTofile,loadFromfile读写connectionString,方便些。
 
BeforeConnect
 
ADOConnection.Connected :=False;
ADOConnection.LoginPrompt:=false;
ADOConnection.ConnectionString :='Provider=SQLOLEDB.1;Password='+DatabasePassword+
';Persist Security Info=True;User ID='+DatabaseUserName+';Initial Catalog='+DBNAME+';Data Source='+Server_Name;
ADOConnection.Connected:=true;
其中DatabasePassword、DatabaseUserName、DBNAME、Server_Name由外部输入。
 
我已经解决问题了。其实我是想问在什么地方,什么时机设置ConnectionString.因为系统
中只起一个连接,我在系统刚开始启动的某个时机拼了ConnectionString,结构正如duqionghui1
所说。
不过再问一下,如何保证密码不被暴露,该不会在INI文件中放个加密后的数据库密码吧。
 
顶部