There are 3 related tables in the database. I want to make a class in which there will be variables with the name of all columns from 3 tables, and methods that would make selections and write data to these variables. And on the form, this data was displayed on the components. Conversely, when writing, the data from the form would be transferred to variables of this class and recorded in the database. I do this so that in the class all sorts of checks for null are carried out, for compliance, in some data the value is increased by 1 (this is for the Index in the ComboBox), etc. It seems like I did everything:
public class PreBlock { public int BlockNumber; public string BlockIndex; public int BlockMass; public int Category; public string CritOtkl; public string OtklSKP; //Аппарат востановления public int VostProcNumber; public int nCondensat; public int nVostRetorta; public int nVostCover; public int nChvost; public int nSlivPipe; // ... и еще много других переменных из таблиц //метод для выборки по заданому блоку public void Prepare(int block) { //здесь обычная выборка и запись во все вышеперечисленные переменные } public void saveBlock { //здесь наоборот запись в таблицы по данным из переменных } } //класс формы public partial class Blocks : Form { PreBlock bl; //объект класса int block; //номер блока для выборки Prepare public Blocks() { //создаю объект класса и запрос bl = new PreBlock(); bl.Prepare(block); //далее уже присваиваю значение компонентам из класса BlockMass.Value = bl.BlockMass; Category.Value = bl.Category; //далее по аналогии присваиваю } //перед сохранением присваиваю значение компонентов переменным из класса PreBlock public void SyncBlock() { bl.BlockMass = BlockMass.Value; bl.Category = Category.Value; //далее по аналогии присваиваю //и вот тут возникает ошибка: //"Ссылка на объект не указывает на экземпляр объекта." }