我想动态修改BDE配置,可在执行时提示session name missing ,请问要怎样解决,程序可以编译成功!(30分)

  • 主题发起人 主题发起人 nfsong
  • 开始时间 开始时间
N

nfsong

Unregistered / Unconfirmed
GUEST, unregistred user!
var BDElist:TstringList;<br> &nbsp; &nbsp;Session1:Tsession;<br>begin<br> {本函数的功能是:动态创建,BDE数据库别名:W_db}<br> &nbsp;BDEList:=TStringList.Create();<br> &nbsp;session1:=Tsession.Create(self);<br> &nbsp;Session1.GetAliasNames(BDElist); // 获取系统所有BDE别名列表<br> &nbsp; &nbsp;if BDEList.IndexOf(trim(w_db.Text))&lt;&gt;-1 then // 如果没有我们的BDE别名&quot;w_db&quot;<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;Session1.DeleteAlias(trim(w_db.Text));<br> &nbsp; &nbsp; &nbsp; &nbsp;session1.SaveConfigFile;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;try<br> &nbsp; &nbsp; &nbsp; &nbsp;BDEList.Clear;<br> &nbsp; &nbsp; &nbsp; &nbsp;BDEList.Add('DATABASE NAME='+trim(w_db.Text)); // 数据库<br> &nbsp; &nbsp; &nbsp; &nbsp;BDeList.Add('SERVER NAME='+trim(w_host.Text));<br> &nbsp; &nbsp; &nbsp; &nbsp;BDEList.Add('USER NAME='+trim(w_use.Text)); // 用户名<br> &nbsp; &nbsp; &nbsp; &nbsp;BDEList.Add('PASSWORD='+trim(w_pwd.Text));<br> &nbsp; &nbsp; &nbsp; &nbsp;BDEList.Add('SQLqrymode=server');<br> &nbsp; &nbsp; &nbsp; &nbsp;BDEList.Add('Sqlpassthru mode=SHARED AUTOCOMMIT');<br> &nbsp; &nbsp; &nbsp; &nbsp;Session1.AddAlias(trim(w_db.Text),'MSSQL',BDEList); // 添加一个mssql类型的BDE别名<br> &nbsp; &nbsp; &nbsp; &nbsp;Session1.SaveConfigFile; // 存储BDE配置<br> &nbsp;finally<br> &nbsp; &nbsp;BDEList.Free;<br> &nbsp;end;<br>end;
 
怎么没人理我,我是初学者,希望大家帮我!谢谢.
 
我已经想出来了
 
后退
顶部