Public Function DbConnect() As Boolean
On Error GoTo error_handle
If gConn.State = ConnectionState.Closed Then
gConn = New SqlConnection
With gConn
.ConnectionString = "Data Source=N-EF4D3A3330684;Initial Catalog=account;Integrated Security=True"
'.ConnectionString = "Data Source=orcl_ao.hcwml.com;User Id=sak;Password=tc123456"
gConn.Open()
'MsgBox("Connection Complete", vbOKOnly + vbInformation, "CONNECTION")
End With
End If
DbConnect = True
Exit Function
error_handle:
MsgBox(Err.Description & Chr(10) & "Error: Can not connect to database" & _
"Please contact administrator", _
vbOKOnly, "ConnectDB Error")
DbConnect = False
End Function
End Module
Tag : .NET, Ms SQL Server 2008, VS 2008 (.NET 3.x)