如何转换
Public Shared Function GetStrConn(Optional ByVal vBolNeedCheckdata As Boolean = False) As String
On Error GoTo PROC_ERROR
Dim DBSet As New WinConfig
Dim StrConn As String
Dim Conn As New SqlClient.SqlConnection
Dim myCMD As SqlClient.SqlCommand
Dim StrSQL As String
Dim myReader As SqlClient.SqlDataReader
DBSet.XmlFileName = Microsoft.VisualBasic.Compatibility.VB6.GetPath & "\" & "WinConfig.xml"
DBSet.WindowName = "Data"
StrConn = "data source=" & DBSet.ReadData("ServerName") & ";initial catalog=" & DBSet.ReadData("DateBase") & ";password=" & DBSet.ReadData("PassWord") & ";persist security info=True;user id=" & DBSet.ReadData("User") & ";workstation id=PERMANI;packet size=4096;"
DBSet = Nothing
If vBolNeedCheckdata = True Then
'! 测试数据库
Conn.ConnectionString = StrConn
'If Conn.State = ConnectionState.Closed Then Conn.Open()
StrSQL = "select top 1 T_FileName from TM_FileVer"
myCMD = New SqlClient.SqlCommand(StrSQL, Conn)
If myCMD.Connection.State = ConnectionState.Closed Then
myCMD.Connection.Open()
End If
myReader = myCMD.ExecuteReader
myReader.Read()
If myCMD.Connection.State = ConnectionState.Open Then myCMD.Connection.Close()
End If
GetStrConn = StrConn
PROC_EXIT:
'* 此处可添加对变量的释放
If Not myReader Is Nothing Then
If myReader.IsClosed = False Then myReader.Close()
myReader = Nothing
End If
If Not myCMD Is Nothing Then
If myCMD.Connection.State = ConnectionState.Open Then myCMD.Connection.Close()
myCMD.Dispose()
End If
If Not Conn Is Nothing Then
Conn.Dispose()
End If
Exit Function
PROC_ERROR:
'* 此处为对错误的处理
GetStrConn = ""
MsgBox("数据库链接错误,请检查网络是否畅通,服务是否开启!", 48, "系统提示")
GoTo PROC_EXIT
End Function
请问这段VB代码,如何转换为C#