Charlotte Foust
cfoust at infostatsystems.com
Thu Jul 19 12:49:44 CDT 2007
Well, if you were REALLY lucky, you'd have someone saying "that works, but I think I'd do it this way". There isn't a single right way, there are just more suitable ways for the present problem. That's what can get really maddening. Of course you do have this list to play in, and it might help others to see how you're approaching a problem too. Charlotte -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Thursday, July 19, 2007 10:36 AM To: dba-vb at databaseadvisors.com Subject: Re: [dba-VB] VB.Net - Option Strict disallows implicit conversion Well, I'm (slowly) learning how to do it. Unfortunately because I work alone it is tough to get the "doing it right" part. If I do it wrong there is no one looking over my shoulder telling me to "do it this way". John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: Thursday, July 19, 2007 12:48 PM To: dba-vb at databaseadvisors.com Subject: Re: [dba-VB] VB.Net - Option Strict disallows implicit conversion We're LEARNING how to do it right OJT! LOL Our senior developer was the only one who had any previous experience with .Net and we've blown past the firm we hired to advise us at the start of the project. And yes, it's been a lot of fun being in it from the ground up. Charlotte -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Thursday, July 19, 2007 9:24 AM To: dba-vb at databaseadvisors.com Subject: Re: [dba-VB] VB.Net - Option Strict disallows implicit conversion Boy I must say you lucked out getting that job. I would die for an opportunity to learn VB.Net OJT AND though a company that apparently really knows how to do it right! John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: Thursday, July 19, 2007 12:13 PM To: dba-vb at databaseadvisors.com Subject: Re: [dba-VB] VB.Net - Option Strict disallows implicit conversion John, We use typed datasets to handle the serialization. Then we can work with the typed dataset in design view as if it were a real table. We do NOT hand build that code! It was easy to generate typed datasets in 2003 but I keep forgetting how in 2005. It is well worth exploring though for the work it saves. >>I was just about to ask about binding this to a form when your next email came in. The only question I have is, is it possible to bind to a class where the open event of the form itself is going to load the data into the class? It seems kinda "cart before the horse". What you do is bind to the class, which has no data in it at that point. You have a setup routine in the form that either accepts a dataset or fills the one it already has. That's the advantage to working with the indirect links offered by typed datasets and wrapper classes. We create various Get and Fill methods (Get returns a filled instance of the class object, Fill populates a passed in instance) to accept parameters and populate the class with the data requested. Charlotte Foust -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Thursday, July 19, 2007 8:49 AM To: dba-vb at databaseadvisors.com Subject: Re: [dba-VB] VB.Net - Option Strict disallows implicit conversion I used DirectCast. And it all works. AMAZING!!! Charlotte, you probably use this all of the time. The example code builds a "serializable class" with functions that do the serialization in / out to a data stream, and functions that get a stream from / to a file. Then you build a properties class that inherits the serializable class, which class then allows you to define your properties. Since the properties class inherits the code to serialize itself, it can do so without further adoo. I then use that in my form to store the control data into a properties class instance and can now store that out to an xml file using the .net serializable stuff embedded in the inherited "serializable class". Likewise retrieve it later. I have to say that the dim statement to do the restore is a mess though! To save: Dim lclsIOData As New clsIOData PopulateIODataFromForm(lclsIOData) Dim strFileName As String = lclsIOData.mDataFileName("FormData") lclsIOData.mSave(strFileName) To restore: Dim lclsIOData As clsIOData lclsIOData = DirectCast(clsSerializableData.Load(clsIOData.mDataFileName("FormData"), GetType(clsIOData)), clsIOData) mPopulateFormFromIOData(lclsIOData) It is really a reasonably small amount of code setting up the serializable class, but once done, any data class can be serialized to xml. From what I can understand I could also serialize it to a table if I wanted to simply by having another function that opened a stream to / from a table instead of a file. I will leave that for another day. Cool stuff. I was just about to ask about binding this to a form when your next email came in. The only question I have is, is it possible to bind to a class where the open event of the form itself is going to load the data into the class? It seems kinda "cart before the horse". John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust Sent: Thursday, July 19, 2007 11:09 AM To: dba-vb at databaseadvisors.com Subject: Re: [dba-VB] VB.Net - Option Strict disallows implicit conversion That's one problem I always have with the books too, they tend to use a lot of implicit conversion. Of course, you learn a lot from making the examples work with option strict on. There are various ways to do it, John. You can use a Ctype() function to convert the object to a clsSomething like this: Ctype(SerializeData(....), clsSomething). You can also use a DirectCast function. Charlotte Foust _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com