{*******************************
*将主机信息保存在一个配置文件中*
*******************************}
procedure TFTPManageForm.SaveFTPHostInfo;
var
ServerIni: TIniFile;
begin
ServerIni := TIniFile.Create(Business.System.JSCommon.ModulePath + 'vb60.ini');
ServerIni.WriteString('Server', 'FT',Code.EncryptString('haier',EditHost.Text));
ServerIni.WriteString('Server', 'US',Code.EncryptString('haier',EditUserName.Text));
ServerIni.WriteString('Server', 'PA',Code.EncryptString('haier',EditPassWord.Text));
ServerIni.WriteString('Server', 'PR',Code.EncryptString('haier',EditPort.Text));
ServerIni.UpdateFile;
ServerIni.Free;
end;
{*******************************
****获取配置文件中的主机信息****
*******************************}
procedure TFTPManageForm.GetHostInfo;
var
ServerIni: TIniFile;
begin
ServerIni := TIniFile.Create(Business.System.JSCommon.ModulePath + 'vb60.ini');
EditHost.Text:=Code.DecryptString('haier',ServerIni.ReadString('Server', 'FT', 'FT'));
EditUserName.Text:=Code.DecryptString('haier',ServerIni.ReadString('Server','US','US'));
EditPassWord.Text:=Code.DecryptString('haier',ServerIni.ReadString('Server','PA','PA'));
if not ServerIni.ReadString('Server','PR','PR').Equals('')then
EditPort.Text:=Code.DecryptString('haier',ServerIni.ReadString('Server','PR','PR'));
ServerIni.Free;
end;
补充一个:Code.EncryptString和Code.DecryptString是加密和解密
先NEW一个INI对象,然后用ReadString读取文件内容。
什么数据库啊 数据库不一样连接字符串就不一样
SQL的话
adoconnection1.connectionstring:='Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=data;Data Source=192.168.0.1'
Passwor为密码
User ID为用户名
192.168.0.1是服务器地址