Dim iport As String =
e.Form.Controls("TxtIP").text & ":" &
e.Form.Controls("Txtport").text & ":" &
e.Form.Controls("Txtinterval").text & ":" &
e.Form.Controls("Txttimeout").text
Dim contxt1 As String =
e.Form.Controls("TextBox2").text
Dim contxt2 As String =
e.Form.Controls("TextBox1").text
FileSys.WriteAllText( projectpath
& "/config/config" & Format(Date.now,"yyyyMMdd")
& ".txt",EncryptText(iport & vbcrlf & contxt1 &
vbcrlf & contxt2,"****","****"), False)
2.读取配置文件
BeforeConnectOuterDataSource
'''
If e.name = "rsgl" Then
Dim CnString As String
If filesys.FileExists(ApplicationPath &
"config.txt")
Dim contxt() As String =
DecryptText(filesys.ReadAllText(ApplicationPath &
"config.txt"),"*****","*****").split(vbcrlf)
If contxt.Length > 1 Then
CnString = contxt(1)
Else
MessageBox.show("系统配置文件错误,请联系管理员。","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Syscmd.Project.Exit()
Return
End If
If Connections.TryConnect(CnString) =
True Then
e.ConnectionString = CnString
Else
messagebox.show("无法连接到数据库,请联系管理员。","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Syscmd.Project.Exit()
Return
End If
Else
messagebox.show("没有找到系统配置文件,无法连接到数据,请联系管理员。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Syscmd.Project.Exit()
Return
End If
End If