Re: Passing Dataset to another WinForm

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




On your destination form you need to have a DataSet variable which
references a DataSet object. From here you need to provide a public property
that allows you to set and get the object reference by this variable. Once
this is complete, the source form which contains the DataSet to use creates
the new form, then assigns the dataset to the property. You can then utilise
this DataSet in the new form in the load event.

Your code would look something like this...

// destination form

private DataSet _myDS;
public DataSet MyDS
{
get
{
return _myDS;
}
set
{
// does not create a new dataset,
// but gives the variable a reference to
// the dataset assigned to MyDS
_myDS = value;
}
}


// source form (before displaying/creating the new form)
// - code assumes you have your dataset ready

destForm = new Form();
destForm.MyDS = readyDataSet;
destForm.ShowDialog();



Hope that helps.
Dan.




"JJ" <JJ@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BF1D8535-A1F9-46FB-B0D0-F28145D46032@xxxxxxxxxxxxxxxx
> Hi,
>
> I need to pass a dataset to another win form along with a
> SqldataAdapter.
> I don't want to recreate the SqlDataAdapter again either. So to pass to
> another Win form in my windows form app, do I create the procedure to pass
> by
> ref? Which means I don't need to add ByRef because it is defaulted by ref,
> correct? And in the constructor of the win form that gets created. I need
> to
> add in parameters a DataSet and SqlDataAdapter correct? What is the
> standard
> way of passing datasets around window forms?
>
> Thanks,
>
> JJ


.



Relevant Pages

  • Re: Tips on finding memory leaks
    ... object, which sets its references to other objects to Nothing, and to call it ... Public Property Get RefAs Object ... Private Sub MyProxy_NeedRef ... Public Property Set Link(ByRef RHS As Class1) ...
    (microsoft.public.vb.general.discussion)
  • circular reference
    ... I have a question about circular references and how to avoid it. ... payroll and timesheet. ... Public Property PropWithin() As String ... Public Property PayrollObjectAs WageType ...
    (microsoft.public.dotnet.languages.vb)
  • Possible to work with a true stand alone clone of a forms recordset?
    ... How can I get a copy of a forms RecordSet that isn't affected when the form ... Public Property Set RecordsetB4Requery(ByVal rsRecordsetB4Requery As ... Private Sub Form_Open ... References to Me.RecordsetB4Requery work exactly like a reference to ...
    (microsoft.public.access.formscoding)