简体   繁体   中英

Object reference not set to an instance of an object (null DataSet??)

I am trying to open a form by passing a value to its tableadapter. In the code below Acct has a value but the error is on waterDataSet.AR. Apparently it is null. How can a dataset be null? How would I go about getting around this error thanks! Note that I use the commented out code in other places with no problems!

        public void LoadWaterAcct(String Acct, String tableName)
    {
        //demTableAdapter1.FillByStreet(waterDataSet.DEM, Num, Dir, Street);
       arTableAdapter1.FillByWaterAcct(waterDataSet.AR, Acct);

    }

Thanks!

How can a dataset be null?

DataSet is a reference type, so a variable of type DataSet is null until you assign a DataSet instance to it...

Did you create the FillByWaterAcct query? http://msdn.microsoft.com/en-us/library/kda44dwy.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM