tags:

views:

188

answers:

3

I have a static field in a non static class.

public class DBtools
{
     public static string ConString ="XXXXXXXXX";
}

This field is assigned to property in the code.

SqlDataSource1.ConnectionString = DBtools.ConString;

But after i run this app I'm getting a error Object reference not set to an instance of an object

How come this is happening? It's a static field.

+1  A: 

Maybe the error is referring to SqlDataSource1 being null?

Christian Hayter
+3  A: 

The SqlDataSource1 object has not been initialized.

neolace
+1  A: 

You have a debugger in front of you. Put a break point on that line, and when it stops investigate all the fields/variables/etc involved. It sounds like however SqlDataSource1 is defined, it is currently null.

Marc Gravell