Re: Confused about OOP programming!
Mark Brackett <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
The difference between a file and a database connection, is the magic of connection pooling. --Mark Brackett -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Stuart Laughlin Sent: Friday, March 30, 2007 11:26 AM To: [email protected] Subject: Re: [DOTNET-WINFORMS] Confused about OOP programming! I attempted to send this yesterday, but it never appeared on the list... On 3/29/07, Steve Abaffy <[email protected]> wrote: > > Now the problem I see here is that I am open and closing the same file > twice. Why is that a problem? I do the analogue with databases all the time (i.e. open a connection, read some records, close the connection, user selects record of interest, open a connection, read some detail records, close the connection, etc). > I can of course get around this problem by using a global InputExcelObj but > that seems to violate the do not use global variable rule. As Stacey suggested, you could indeed use a private class-level identifier to reference the Excel object. I think it's asking for trouble, though. If you go this route, you still ought not to assume that the file remains open and accessible via the class-level identifier when the user clicks the 'process file' button. > > What is a better way to do this? And of course if one could use a > ExcelObjClass where you can have methods like GetCellValue, SaveFile, > OpenFileforRead, OpenFileForWrite etc... that would be even better. Aren't those methods (or something very similar) already part of the API? http://msdn2.microsoft.com/en-us/library/aa168292(office.11).aspx --Stuart