Y
ypul
the code below given is connection class ... now I want to use the
connection in another class , by using the getConnection method.
where should I call con.dispose() ?
in connection class or in the caller class ?
if I call con.dispose in connection class as given below ..will I be able to
use the connection in the other class where I am calling this method ..or I
will get a NULL connection ??
-------------------------Code -------------------------
Public Class Connection
Public Shared Function getConnection() As SqlConnection
Dim con As SqlConnection
Try
con = New
SqlConnection(ConfigurationSettings.AppSettings.Get("ConnectionString"))
con.Open()
Return con
Catch ex As SqlException
Throw ex
Finally
con.Close()
con.Dispose()
End Try
End Function
connection in another class , by using the getConnection method.
where should I call con.dispose() ?
in connection class or in the caller class ?
if I call con.dispose in connection class as given below ..will I be able to
use the connection in the other class where I am calling this method ..or I
will get a NULL connection ??
-------------------------Code -------------------------
Public Class Connection
Public Shared Function getConnection() As SqlConnection
Dim con As SqlConnection
Try
con = New
SqlConnection(ConfigurationSettings.AppSettings.Get("ConnectionString"))
con.Open()
Return con
Catch ex As SqlException
Throw ex
Finally
con.Close()
con.Dispose()
End Try
End Function