Gerard,
They are different because you've already defined oAd in your declarations at the top of your class:
protected OleDbDataAdapter oAd;
That makes this.oAd a variable that can be used throughout your class (but it hasn't as yet been instantiated). When you instantiated oAd in your GetData() method with:
OleDbDataAdapter oAd = new OleDbDataAdapter(this.sSelectString ,oCon);
you are, in effect, creating another variable that is local to the GetData() method and this is not the same as the oAd that was created in the declarations of your class (which is referenced by this.oAd and is scoped globally to the entire class).
By replacing the command as I suggested, you are now instantiating the variable that is scoped to the entire class, rather than one that is scoped only to the method. And, you *do* need this class-scoped variable since you are using it in two different methods.
Do you see the difference between the two now or do I need to explain it differently?
~~Bonnie
>Hi Bonnie. Many thanks for your reply.
>That sorted the problem but I dont understand why !!
>
>OleDbDataAdapter oAd = new OleDbDataAdapter(this.sSelectString ,oCon);
> replaced by
>this.oAd = new OleDbDataAdapter(this.sSelectString ,oCon);
>
>Why is there a difference then between the two commands ?
>Are they both not initialising a New OleDbDataAdapter called oAd ?
>
>Regards,
>
>Gerard