Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Urgent - Cant Lock Application

Urgent - Cant Lock Application

Scheduled Pinned Locked Moved Visual Basic
questiondatabasehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kakomalis
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • K 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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups