Data Access Class


Hi All, This is code for a class for data access this class helps you to setup connections to data base…..!
 
Public Class DataAccess
    Public StrConnection As String = "Server=.;Database=TMS;Integrated Security=True"
    Public ObjCon As New SqlConnection
    Sub openDB()
        Try
            ObjCon.ConnectionString = StrConnection
            If (ObjCon.State = ConnectionState.Closed) Then
                ObjCon.Open()
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
    Sub closeDB()
        Try
            If (ObjCon.State = ConnectionState.Open) Then
                ObjCon.Close()
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: