如何动态修改TSQLCONNECTION的连接参数?(100分)

  • 主题发起人 主题发起人 yufanchen
  • 开始时间 开始时间
Y

yufanchen

Unregistered / Unconfirmed
GUEST, unregistred user!
我想动态的改变TSQLCONNCTION的连接PARAMS,用LOADFROM 试了几次没有用,不知道怎么动态的修改?
 
with ConMySQLMainForm do<br>&nbsp; begin<br>&nbsp; &nbsp; ConnectionName := 'xxxxxx';<br>&nbsp; &nbsp; DriverName := 'MySQL';<br>&nbsp; &nbsp; GetDriverFunc := 'getSQLDriverMYSQL';<br>&nbsp; &nbsp; LibraryName := 'dbexpmysql.dll';<br>&nbsp; &nbsp; VendorLib := 'libmysql.dll';<br>&nbsp; &nbsp; LoginPrompt := False;<br>&nbsp; &nbsp; KeepConnection := False;<br>&nbsp; end;<br>&nbsp; ConMySQLMainForm.BeforeConnect := MySQLBeforeConnect;<br>----------------------------------------------------------<br><br>procedure TMain.MySQLBeforeConnect(Sender: TObject);<br>begin<br>&nbsp; with ConMySQLMainForm do<br>&nbsp; begin<br>&nbsp; &nbsp; params.Values['HostName'] := MySQLHostName;<br>&nbsp; &nbsp; params.Values['Database'] := MySQLDataBase;<br>&nbsp; &nbsp; params.Values['User_Name'] := MySQLUser;<br>&nbsp; &nbsp; params.Values['Password'] := MySQLPassword;<br>&nbsp; &nbsp; params.Values['BlobSize'] := '-1';<br>&nbsp; &nbsp; params.Values['ErrorResourceFile'] := '';<br>&nbsp; &nbsp; params.Values['LocaleCode'] := '0000';<br>&nbsp; end;<br>end;
 
建议建立ini文件,用它来保存参数,或者直接写到注册表中,修改时直接修改注册表或者ini,这样下次用时直接调用。
 

Similar threads

后退
顶部