passing dataset reference to another form.

Hello,

I am trying to pass a reference to a dataset that is being used in my main form to a modal dialog form.

The form is being used to add/edit records in a database.

I would like to use the exact same dataset in the other form, as opposed to working with a copy of the dataset.

Any help would be extremely appreciated.

Thanks,
Adam



Answer this question

passing dataset reference to another form.

  • Ibrahim Malluf

    I did try it as just a property, but I ran into a few problems. It seemed that SelectedIndexChange would fire on a combobox in the main form (it would become null), and would call functions that shouldnt of been called. There were other problems as well.

    I did it your way, passing the reference to the dataset, and it worked beautifully. Thank you very much for your help.

    Adam


  • Ardayon

    You could put a property on the Modal Dialog form that is a DataSet property but if you want to use the DataSet as a ref instead, then you could do something like this:

    In the modal form:


    private DataSet _dataSet = null;
    public void SetDataSet(ref DataSet dataSet)
    {
          _dataSet = dataSet;
    }

     

    I am not sure that this is the only way to do this, but it is certainly a way to do this.

    Ben Miller



  • passing dataset reference to another form.