Generic Workspace Class - Class Initialization Question

Generic Workspace Class - Class Initialization Question

Post by Quiet Stor » Wed, 11 Feb 1998 04:00:00



I have the following (slightly altered to protect the innocent):

' Private Class References
Private m_wsMain As Workspace     ' Class Workspace
Private m_dbMain As Database        ' Class Database
Private m_UserName As String         ' User Login Name
Private m_Password As String          ' User Login Password

' Data Constants
Private Const STR_SYSTEMMDW = "\DBytes.mdw" ' Secured Workgroup File

' Workspace error enumeration
Enum wsErrors
    wsOpenMDWError = vbObjectError + 512 + 1000
    wsOpenWSError = vbObjectError + 512 + 1001
End Enum
'*********************************************************************
' Returns a reference to the workspace
Public Property Get GetWorkspace() As Workspace
    Set GetWorkspace = m_wsMain
End Property
'*********************************************************************
Private Sub Class_Initialize()
On Error GoTo ERR_ROUTINE
    ' Use the default work space
    DBEngine.DefaultType = dbUseJet
    DBEngine.SystemDB = App.Path & STR_SYSTEMMDW
    Set m_wsMain = CreateWorkspace("JetWorkspace", m_UserName, m_Password)
End Sub

'*********************************************************************
'*********************************************************************

My question is:  What would be the best way to supply the UserName and
Password so the class can be used with secured or unsecured workgroup files?
Is it best to just hard code it in as a private constant?

I know I could call up a login screen prior to opening the Main Form.
However, if I use this approach, would I be able to bypass the login screen
(similar to the option box to stop showing a splash screen)?  Any
suggestions?

 
 
 

Generic Workspace Class - Class Initialization Question

Post by Richard Magea » Wed, 11 Feb 1998 04:00:00


Why are you opening the workspace in the initialize? I would probably do
something like this:

Private Function Logon(UserName as string, Password as string,IsProtected as
boolean) as workspace

if IsProtected
    set ws = dbengine.createworkspace("blah",Username,Password)
else
    set ws = dbengine.createworkspace("blah")
end if

Put it all in one function call, then call the fuction. make it generic.

--

Don't forget to check out our web page for more great hints!
www.xtremecomp.com


>I have the following (slightly altered to protect the innocent):

>' Private Class References
>Private m_wsMain As Workspace     ' Class Workspace
>Private m_dbMain As Database        ' Class Database
>Private m_UserName As String         ' User Login Name
>Private m_Password As String          ' User Login Password

>' Data Constants
>Private Const STR_SYSTEMMDW = "\DBytes.mdw" ' Secured Workgroup File

>' Workspace error enumeration
>Enum wsErrors
>    wsOpenMDWError = vbObjectError + 512 + 1000
>    wsOpenWSError = vbObjectError + 512 + 1001
>End Enum
>'*********************************************************************
>' Returns a reference to the workspace
>Public Property Get GetWorkspace() As Workspace
>    Set GetWorkspace = m_wsMain
>End Property
>'*********************************************************************
>Private Sub Class_Initialize()
>On Error GoTo ERR_ROUTINE
>    ' Use the default work space
>    DBEngine.DefaultType = dbUseJet
>    DBEngine.SystemDB = App.Path & STR_SYSTEMMDW
>    Set m_wsMain = CreateWorkspace("JetWorkspace", m_UserName, m_Password)
>End Sub

>'*********************************************************************
>'*********************************************************************

>My question is:  What would be the best way to supply the UserName and
>Password so the class can be used with secured or unsecured workgroup
files?
>Is it best to just hard code it in as a private constant?

>I know I could call up a login screen prior to opening the Main Form.
>However, if I use this approach, would I be able to bypass the login screen
>(similar to the option box to stop showing a splash screen)?  Any
>suggestions?


 
 
 

1. best class initialization

Hi group,

I am rather dazzled now. Supposed we have a Person class. What is the best
way for us to load the Person from the database?

What I am doing is I have within my Person class the code to load from
database asf;

//assuming the connection is there
class Person{
        public Person(int id){
                ....
                this.setId(rs.getInt("id");
                ....
        }

I am not sure whether this is the best method to do it. It makes my Person
class coding look spaghetti like. Especially when I have to overload it with
save() method, delete() method and other method that allow manipulation from
the database. Can any one point out to me the best pattern or practice how
to achieve such? I want cleaner code but not sure on how to do it.

Thanks a lot

2. Size of TNSNames file a problem?

3. Generic SQL c++ class for client/server

4. Oracle 6 odbc connectivity

5. Generic ADO Class

6. paradox blows me away

7. Generic SQL c++ class for client/server

8. Trigger question

9. Generic Database Class

10. changing the parent class of a class

11. Form 6.0 Class vs. Forms 2.0 Class

12. Visual C++ ADO- linking to wrapper classes gives link errror but not raw classes

13. ATL COM Class Final Construct dies with Member Accessor Class