468,512 Members | 1,419 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

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

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

------
Thanks in advance for any help.
Nov 20 '05 #1
4 2824
Cor
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
Nov 20 '05 #2
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
"Gr8North" <ae******@mad.com> wrote in message
news:uc**************@TK2MSFTNGP12.phx.gbl...
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

------
Thanks in advance for any help.

Nov 20 '05 #3
Resolved this.

Just passed as type Dataset instead of object.
"Gr8North" <ae******@mad.com> wrote in message
news:uc**************@TK2MSFTNGP12.phx.gbl...
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

------
Thanks in advance for any help.

Nov 20 '05 #4
Cor
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
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Glenn Venzke | last post: by
3 posts views Thread by Simon Harvey | last post: by
4 posts views Thread by Sahil Malik [MVP] | last post: by
25 posts views Thread by Stuart Hilditch | last post: by
1 post views Thread by Larry Bird | last post: by
22 posts views Thread by Arne | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.