Urgent - Cant Lock Application
-
Hello, I have a class in my web application that is used to connect to the database and submit or gain data from my tables. The class is called dataAccess and is as follow: Public Class DataAccess Private Function Connect() As SqlClient.SqlConnection Try myConnection = New SqlClient.SqlConnection myConnection.ConnectionString = myConnectionString myConnection.Open() Return myConnection Catch ex As Exception 'Database Cannot be reached Return Nothing End Try End Function Protected Friend Function alertDatabase(ByVal myQuery As String) As Boolean Dim myCommand As SqlClient.SqlCommand Try 'Application.Lock() myCommand = New SqlClient.SqlCommand(myQuery, Connect()) myCommand.ExecuteNonQuery() DisConnect() 'Application.UNLock() Return True Catch ex As Exception DisConnect() Return False End Try End Function End Class At Application.Lock() my compiler says that namespace is not declare!!! how can i solve this problem? Can i declare the application? Thanks in advance, Kakomalis
-
Hello, I have a class in my web application that is used to connect to the database and submit or gain data from my tables. The class is called dataAccess and is as follow: Public Class DataAccess Private Function Connect() As SqlClient.SqlConnection Try myConnection = New SqlClient.SqlConnection myConnection.ConnectionString = myConnectionString myConnection.Open() Return myConnection Catch ex As Exception 'Database Cannot be reached Return Nothing End Try End Function Protected Friend Function alertDatabase(ByVal myQuery As String) As Boolean Dim myCommand As SqlClient.SqlCommand Try 'Application.Lock() myCommand = New SqlClient.SqlCommand(myQuery, Connect()) myCommand.ExecuteNonQuery() DisConnect() 'Application.UNLock() Return True Catch ex As Exception DisConnect() Return False End Try End Function End Class At Application.Lock() my compiler says that namespace is not declare!!! how can i solve this problem? Can i declare the application? Thanks in advance, Kakomalis
I'm guessing that this is a seperate class file from your ASP web form. Try adding
Imports System.Web
to the top of your DataAccess class file. BTW: Your data layer classes, properly written, shouldn't care about what type of application is using them. Your code is using a web application Lock method where it shouldn't have to. The data layer should never have this kind of dependancy. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome