public partial class _Default: System.Web.UI.Page
Defines one class named _
Default
that inherits from
System.Web.UI.Page
. The
partial keyword instructs the compiler to not generate errors for not finding at this scope the entire declarations and definitions for the class
_Default
. The rest of the class should be provided in another similar declaration (using the
partial keyword also).
private static readonly string _connString = String.Empty;
Declares one private (scoped to the class, invisible out of there) field which can not be written (that's the meaning of
readonly). The
static keyword specifies that this field will be global (shared by) to all instances of that class.
Code writing to static fields is not reentrant, take care with that.
One thing else, the fact that it is marked
readonly implies that it can not be changed, so it makes no sense to initialize it with the value
String.Empty
if it will be used later like your code does.
SqlConnection con = new SqlConnection(_connString);
This creates one instance of the class
SqlConnection()
. Take a look at this, as
_connString
can not be modified and has been initialized with an empty string... presumably you'll not be able to establish the connection with this code.
Perhaps you should consider removing
static and
readonly from your
_connString
declaration.