📄 csetcninfo.vb
字号:
'将数据服务器信息序列化为xml文件的类
Imports System.Xml.Serialization
Imports System.IO
Imports System.Collections
Public Class CsetCnInfo
Structure CnInfo
Public server As String
Public database As String
Public uid As String
Public password As String
End Structure
Private mCC(4) As String
Public Function setCnTofile()
Dim mcn As CnInfo
mcn.server = mCC(0)
mcn.database = mCC(1)
mcn.uid = mCC(2)
mcn.password = mCC(3)
Dim xmlS As New XmlSerializer(GetType(CnInfo))
Dim txtwt As TextWriter = New StreamWriter("cninfo.xml")
xmlS.Serialize(txtwt, mCn)
txtwt.Close()
End Function
Public Function GetCnFromfile() As String
Dim mcn As CnInfo
Dim xmls As New XmlSerializer(GetType(CnInfo))
Dim txtwt As TextReader = New StreamReader("cninfo.xml")
Try
mcn = xmls.Deserialize(txtwt)
mCC(0) = mcn.server
mCC(1) = mcn.database
mCC(2) = mcn.uid
mCC(3) = mcn.password
Catch ex As Exception
Throw ex
Finally
txtwt.Close()
End Try
Return returnCnstr()
End Function
Public Function returnCnstr() As String
Return "server=" + mCC(0) + ";database=" _
+ mCC(1) + ";uid=" + mCC(2) + ";pwd=" + mCC(3)
End Function
Public Property cnstr() As String()
Get
Return mCC
End Get
Set(ByVal Value As String())
Value.CopyTo(mCC, 0)
End Set
End Property
Public Sub New()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -