Hello Friends....One more doubt...
I have a connection module in which I have written the open and close database connection....
if database connection is an error it will return false else if success it will return true
the function of the modules will be called from the form code....
what I need is if the connection is an error the module should also get the form name which returned the error...is it possible???
check my below code....
DBConnection.module
Imports System.Data.SqlClient
Module DBConnection
Public Connection As SqlConnection = New SqlConnection()
Public Function Open_DB_Connection() As String
Try
Connection.ConnectionString = "Data Source = LocalHost\;Initial Catalog = Database;Integrated Security = True"
Connection.Open()
Return "Success"
Catch ex As Exception
MsgBox("Connection Error: " + ex.Message)
Return "Fail"
Exit Function
End Try
End Function
Public Function Close_DB_Connection() As String
Try
Connection.Close()
Return "Success"
Catch ex As Exception
MsgBox("Connection Error: " + ex.Message)
Return "Fail"
Exit Function
End Try
End Function
End Module
Call from the function is this way....
Dim Open_DB_Con As String
Dim Close_DB_Con As String
Open_DB_Con = Open_DB_Connection()
'other stuff required like queries....
Close_DB_Con = Close_DB_Connection()
now what I need is if the functions Open_DB_Connection() or Close_DB_Connection() returns error it should prompt the form name....
is it possible?? to code it in module....
thanks for help in advance....