J
Jeff Jarrell
I am sure this has been discussed many times before, so I apologize up
front. I did google the topic but I didn't seem to hit on the issue at hand.
I am migrating a significant codebase from vb6 to vb.net. I have been
working on appropriate abstractions of the data layers (nifty stuff behind
the scenes) but when I ultimately get to how it looks to the application
programmer (as in how much change is necessary in the old code). I am stuck
with how to keep option strict on without having to cast everything in
sight. (Or use type-safe getters.)
I don't need to debate option strict. Seems to be a strong consensus that
it should be on. Now to keep my port fast I need to make something that
looks like a ado recordset. presently the .field property returns an
object. But is there no way to code around this specific issue. The fewer
changes at the application level the better. I do have complete freedom in
the data access layers.
Now correct me if I am wrong, but now that I am all about option strict on,
I have created a dependency in my code to the schema of the database.
schema changes (a data type changes) my code breaks.
In our vb6 app we had a wrapper around an ADO record set. It had some
programmer usability features and enhancements in terms of error handling.
Here is a typical coding pattern.
------------------------------------------------------------
sSQL = "select * from oewmssec where user_name = '%s'"
sSQL = wsprintf(sSQL, sUserName)
Call rs.openFile(sSQL, adoCon, sSQL, adOpenForwardOnly, adLockReadOnly)
If Not rs.EOF Then
sWMSUser = rs.Field("user_name")
bShippingAuthorized = rs.Field("shipping")
bReceivingAuthorized = rs.Field("receiving")
endif
rs.close
set rs = nothing
-------------------------------------------------------------
The rs.field property returns a variant which in turn is implictly cast.
Now if i start do it the vb.net\ado.net way with option strict on, i have to
include casts or create type-safe getters. (the .field property returns an
object).
sSQL = "select * from oewmssec where user_name = '%s'"
sSQL = wsprintf(sSQL, sUserName)
Call rs.openFile(sSQL, adoCon, sSQL, adOpenForwardOnly, adLockReadOnly)
If Not rs.EOF Then
sWMSUser = ctype(rs.Field("user_name"),string)
' cast
bShippingAuthorized = ctype(rs.Field("shipping"),boolean)
bReceivingAuthorized = rs.getBoolean("receiving")
'typesafe getter
endif
==========
so is this it? my destiny? inserting "ctype(" accross thousands of lines
of code.
thanks
jeff
==========
front. I did google the topic but I didn't seem to hit on the issue at hand.
I am migrating a significant codebase from vb6 to vb.net. I have been
working on appropriate abstractions of the data layers (nifty stuff behind
the scenes) but when I ultimately get to how it looks to the application
programmer (as in how much change is necessary in the old code). I am stuck
with how to keep option strict on without having to cast everything in
sight. (Or use type-safe getters.)
I don't need to debate option strict. Seems to be a strong consensus that
it should be on. Now to keep my port fast I need to make something that
looks like a ado recordset. presently the .field property returns an
object. But is there no way to code around this specific issue. The fewer
changes at the application level the better. I do have complete freedom in
the data access layers.
Now correct me if I am wrong, but now that I am all about option strict on,
I have created a dependency in my code to the schema of the database.
schema changes (a data type changes) my code breaks.
In our vb6 app we had a wrapper around an ADO record set. It had some
programmer usability features and enhancements in terms of error handling.
Here is a typical coding pattern.
------------------------------------------------------------
sSQL = "select * from oewmssec where user_name = '%s'"
sSQL = wsprintf(sSQL, sUserName)
Call rs.openFile(sSQL, adoCon, sSQL, adOpenForwardOnly, adLockReadOnly)
If Not rs.EOF Then
sWMSUser = rs.Field("user_name")
bShippingAuthorized = rs.Field("shipping")
bReceivingAuthorized = rs.Field("receiving")
endif
rs.close
set rs = nothing
-------------------------------------------------------------
The rs.field property returns a variant which in turn is implictly cast.
Now if i start do it the vb.net\ado.net way with option strict on, i have to
include casts or create type-safe getters. (the .field property returns an
object).
sSQL = "select * from oewmssec where user_name = '%s'"
sSQL = wsprintf(sSQL, sUserName)
Call rs.openFile(sSQL, adoCon, sSQL, adOpenForwardOnly, adLockReadOnly)
If Not rs.EOF Then
sWMSUser = ctype(rs.Field("user_name"),string)
' cast
bShippingAuthorized = ctype(rs.Field("shipping"),boolean)
bReceivingAuthorized = rs.getBoolean("receiving")
'typesafe getter
endif
==========
so is this it? my destiny? inserting "ctype(" accross thousands of lines
of code.
thanks
jeff
==========