Variable scope errors
-
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...
-
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...
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!