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. C#
  4. Variable scope errors

Variable scope errors

Scheduled Pinned Locked Moved C#
csharpasp-net
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.
  • S Offline
    S Offline
    Steve Severance
    wrote on last edited by
    #1

    I am working on an ASP.NET app. In my global.asax I have a publicly exposed SqlConnection. Everything was working fine until I changed the connection string. Now all the places I used it say "An object reference is required for the nonstatic field, method, or property 'Pharmacy.Global.sqlConnection'". All I did was change the connection string. It is still public. Thanks. Steve Not all who wander are lost...

    J 1 Reply Last reply
    0
    • S Steve Severance

      I am working on an ASP.NET app. In my global.asax I have a publicly exposed SqlConnection. Everything was working fine until I changed the connection string. Now all the places I used it say "An object reference is required for the nonstatic field, method, or property 'Pharmacy.Global.sqlConnection'". All I did was change the connection string. It is still public. Thanks. Steve Not all who wander are lost...

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      Steve Severance wrote: "An object reference is required for the nonstatic field, method, or property 'Pharmacy.Global.sqlConnection' This error leads me to believe that sqlConnection is not a static field of the global.asax, the quick fix is to make it a static field (public static SqlConnection sqlConnection) HTH, James Simplicity Rules!

      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