Passing Datasets as Object - Strict On - How get type?

  • Thread starter Thread starter Gr8North
  • Start date Start date
G

Gr8North

I'm relatively new to .Net, and would appreciate a little assistance.

I have multiple datasets attached to individual grids on individual tabs on
a form.

I would like to have a series of generic functions such as SaveChange,
RejectChanges, passing a grid and related dataset. As the datasets are
different types, I'm passing them as an object. I dont wish to override the
function with multiple copies and duplicated code.

However, Option Strict On, disallows late binding.

I've tried ds.gettype and passing the ds type, but cant figure it out.

Pseudo code

if tabName = "A" then
SaveChanges( gridA, dsA)
elseif tabName = "B" then
SaveChanges( gridB, dsB)
' many more
end if


Sub SaveChanges( ByVal grid as Infragistics.Win.UltraWinGrid.UltraGrid,
ByVal ds As Object )

' Code removed

if ds.haschanges then
ds.update
end if

end sub
 
Hi Gr8north,

Why do you need that grid when you are updating the dataset.

In my opinion you can better think from your source (the dataset) than from
your view (the datagrid).

I myself give a lot of things to routines which are the same as you made
(even the command to get easy parameter handling) but not the datagrid.

I have never had any problems with late binding in that.
(Although when it was, it would not be a problem for me, but that is not
what I mean with that sentence)

Cor
 
Remember, a typed dataset inherits from System.Data.Dataset, so you don't
need to pass it as object.

Second, Option Strict does not disallow late binding, it requires strong
typecasting at design time.

i.e.

Option Strict Off

Public class myclass

private i as integer
private d as decimal

public sub go()

d= 10.3
i = d
''' results in i = 10
end sub
end class

where with option strict on... doing the same thing would cause a compile
error. because you would need to do a

i = ctype(d, integer)

I don't know if tihs will work off the fly, I'm just typing it in here.. but
hopefully you get the point...

-CJ
 
Hi CJ,

Did not see it, but here it has been dinnertime maybe that is the reason.

(It is not, I can tell you, just my stupidity not to see it)

:-)

Cor
 
Back
Top