professional visual basic 6 project management

Download Professional Visual Basic 6 Project Management

If you can't read please download the document

Upload: lenhi

Post on 08-Dec-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

VB Proj Man/Testing/frmTest.frmVERSION 5.00Begin VB.Form frmTest Caption = "VB Project Management" ClientHeight = 2496 ClientLeft = 48 ClientTop = 336 ClientWidth = 3744 LinkTopic = "Form1" ScaleHeight = 2496 ScaleWidth = 3744 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmdTest Caption = "Test" Height = 492 Left = 960 TabIndex = 0 Top = 1200 Width = 1692 EndEndAttribute VB_Name = "frmTest"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption Explicit Dim WithEvents m_oCustomerRS As ADODB.RecordsetAttribute m_oCustomerRS.VB_VarHelpID = -1

Private Sub m_oCustomerRS_WillChangeField(ByVal cFields As Long, ByVal Fields As Variant, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) BeepEnd Sub

Private Sub cmdTest_Click() Dim oLog As LogFile Dim sReturnValue As String Set oLog = New LogFile Set m_oCustomerRS = New ADODB.Recordset m_oCustomerRS.CursorLocation = adUseClient m_oCustomerRS.CursorType = adOpenStatic Set m_oCustomerRS = oLog.GetRecordset oLog.ChangeRecordset m_oCustomerRS

End Sub

VB Proj Man/Testing/Group1.vbgVBGROUP 5.0Project=prjLog.vbpStartupProject=prjTest.vbp

VB Proj Man/Testing/LogFile.clsVERSION 1.0 CLASSBEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 3 'UsesTransactionENDAttribute VB_Name = "LogFile"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = TrueAttribute VB_PredeclaredId = FalseAttribute VB_Exposed = TrueOption Explicit Private m_objADOConnection As ADODB.ConnectionPrivate m_objContext As ObjectContextPrivate Const m_cstrDatabasePath As String = "C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb"Implements ObjectControl

Private Sub ObjectControl_Activate() Set m_objContext = GetObjectContextEnd Sub

Private Function ObjectControl_CanBePooled() As Boolean ObjectControl_CanBePooled = FalseEnd Function

Private Sub ObjectControl_Deactivate() Set m_objADOConnection = Nothing Set m_objContext = NothingEnd Sub

Private Function CreateInstance(ProgID As String) As Object On Error GoTo CreateInstanceError If Not m_objContext Is Nothing Then Set CreateInstance = m_objContext.CreateInstance(ProgID) Else Select Case ProgID Case "ADODB.Connection" Set CreateInstance = New ADODB.Connection Case "ADODB.Recordset" Set CreateInstance = New ADODB.Recordset End Select End If

Exit Function

CreateInstanceError:

Err.Raise Err.Number, Err.Source & " CreateInstance", Err.Description End Function

Private Sub SetADOConnection(ByVal v_strUserID As String, _ ByVal v_strPassword As String, Optional ByVal _ v_sConnectionString As String = "Empty") On Error GoTo SetADOConnectionError Set m_objADOConnection = CreateInstance("ADODB.Connection") With m_objADOConnection .CursorLocation = adUseServer If v_sConnectionString = "Empty" Then .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Persist Security Info=False;Data Source=" & _ m_cstrDatabasePath Else .ConnectionString = v_sConnectionString End If .Open End With

Exit SubSetADOConnectionError:

Dim lngErrorCounter As Long Dim strErrors As String

strErrors = Err.Number & ": " & Err.Description

If m_objADOConnection.Errors.Count > 0 Then

For lngErrorCounter = 0 To m_objADOConnection.Errors.Count - 1 strErrors = strErrors & _ m_objADOConnection.Errors(lngErrorCounter).Number & _ ": " & m_objADOConnection.Errors(lngErrorCounter).Description & _ vbCrLf Next lngErrorCounter

End If Err.Raise Err.Number, "SetADOConnection", strErrors End Sub Private Function GetADOConnection() As ADODB.Connection If m_objADOConnection Is Nothing Then Err.Raise 2001, "GetADOConnection", _ "Trying to Get Connection prior to setting it" Else Set GetADOConnection = m_objADOConnection

End If End Function Private Sub CloseADOConnection() With GetADOConnection If .State = adStateOpen Then .Close End If

End With End Sub

Public Function GetRecordset() As ADODB.Recordset Dim strADOConnection As String Dim objCustomersRS As ADODB.Recordset On Error GoTo GetRecordsetError

strADOConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & m_cstrDatabasePath & _ ";Persist Security Info=False" SetADOConnection "", "", strADOConnection Set objCustomersRS = New ADODB.Recordset objCustomersRS.CursorLocation = adUseClient objCustomersRS.CursorType = adOpenStatic objCustomersRS.LockType = adLockPessimistic objCustomersRS.Source = "Customers" Set objCustomersRS.ActiveConnection = GetADOConnection objCustomersRS.Open Set objCustomersRS.ActiveConnection = Nothing Set GetRecordset = objCustomersRS CloseADOConnection Exit FunctionGetRecordsetError: CloseADOConnection Err.Raise Err.Number, Err.Source & " GetRecordset", Err.Description End Function

Public Sub ChangeRecordset(ByVal v_oCustomerRS As ADODB.Recordset) v_oCustomerRS.Fields("ContactTitle") = "NewValue" End Sub

VB Proj Man/Testing/MSSCCPRJ.SCC[SCC]SCC=This is a source code control file

[prjLog.vbp]SCC_Project_Name=this project is not under source code controlSCC_Aux_Path=

[prjTest.vbp]SCC_Project_Name=this project is not under source code controlSCC_Aux_Path=

VB Proj Man/Testing/prjLog.dll

VB Proj Man/Testing/prjLog.expL7.edatad@@.debug$SX@B7prjLog.dllDllCanUnloadNowDllGetClassObjectDllRegisterServerDllUnregisterServer $(8, 0 Then

For lngErrorCounter = 0 To m_objADOConnection.Errors.Count - 1 strErrors = strErrors & _ m_objADOConnection.Errors(lngErrorCounter).Number & _ ": " & m_objADOConnection.Errors(lngErrorCounter).Description & _ vbCrLf Next lngErrorCounter

End If WriteToTextFile App.EXEName, "LogFile", "SetADOConnection", _ "Connection Failed", Informational End Sub

Private Function GetADOConnection() As ADODB.Connection If m_objADOConnection Is Nothing Then Err.Raise 2001, "GetADOConnection", _ "Trying to Get Connection prior to setting it" Else Set GetADOConnection = m_objADOConnection

End If End Function Private Sub CloseADOConnection() With GetADOConnection If .State = adStateOpen Then .Close End If

End With End Sub

Public Function GetRecordset() As ADODB.Recordset Dim strADOConnection As String Dim objCustomersRS As ADODB.Recordset On Error GoTo GetRecordsetError

strADOConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & m_cstrDatabasePath & _ ";Persist Security Info=False" SetADOConnection "", "", strADOConnection Set objCustomersRS = New ADODB.Recordset objCustomersRS.CursorLocation = adUseClient objCustomersRS.CursorType = adOpenStatic objCustomersRS.LockType = adLockPessimistic objCustomersRS.Source = "Customers" Set objCustomersRS.ActiveConnection = GetADOConnection objCustomersRS.Open Set objCustomersRS.ActiveConnection = Nothing Set GetRecordset = objCustomersRS CloseADOConnection Exit FunctionGetRecordsetError: CloseADOConnection Err.Raise Err.Number, Err.Source & " GetRecordset", Err.Description End Function

Public Sub ChangeRecordset(ByVal v_oCustomerRS As ADODB.Recordset) v_oCustomerRS.Fields("ContactTitle") = "NewValue" End Sub

VB Proj Man/Error Log/MSSCCPRJ.SCC[SCC]SCC=This is a source code control file

[prjErrorLog.vbp]SCC_Project_Name=this project is not under source code controlSCC_Aux_Path=

[prjTest2.vbp]SCC_Project_Name=this project is not under source code controlSCC_Aux_Path=

VB Proj Man/Error Log/prjErrorLog.dll

VB Proj Man/Error Log/prjErrorLog.expL7.edatad@@.debug$S_@B7prjErrorLog.dllDllCanUnloadNowDllGetClassObjectDllRegisterServerDllUnregisterServer $(8, 0 Then Dim lngLocationSpace As Long Dim lngLengthString As Long Dim strFieldName As String strFieldName = r_sFieldNames(lngFieldCounter) lngLocationSpace = InStr(1, strFieldName, " ") lngLengthString = Len(strFieldName) r_sFieldNames(lngFieldCounter) = _ Left(strFieldName, lngLocationSpace - 1) & _ Right(strFieldName, lngLengthString - lngLocationSpace) End If LoopNextEnd Sub

VB Proj Man/Code Generator/BuildBas.basAttribute VB_Name = "buildBas"Option Explicit

Public Function CreateDeclarations _ (ByRef v_uFieldInfo() As FieldInformation, _ ByVal v_sPrimaryKey As String, _ ByVal v_sTableName As String)

Dim lngFieldCounter As LongDim strCode As StringDim strFieldNames() As String

CleanFields v_uFieldInfo, strFieldNames

Dim strTableName As StringstrTableName = v_sTableNameDo Until InStr(strTableName, " ") = 0 Dim lngSpace As Long lngSpace = InStr(strTableName, " ") strTableName = Left(strTableName, lngSpace - 1) & _ Right(strTableName, Len(strTableName) - lngSpace)LoopstrCode = strCode & "Public Enum " & strTableName & "Errors" & _ Chr(13) & Chr(10)

strCode = strCode & " errChangeFieldNoEdit = 1001" & Chr(13) & Chr(10)strCode = strCode & " errEditPrimaryKey = 1002" & Chr(13) & Chr(10)strCode = strCode & " errPrimaryKeyLength = 1003" & Chr(13) & Chr(10)strCode = strCode & "End Enum" & Chr(13) & Chr(10)

For lngFieldCounter = 1 To UBound(v_uFieldInfo) strCode = strCode & "Public Const g_cstrField" & _ strFieldNames(lngFieldCounter) & " As String = " & _ Chr(34) & v_uFieldInfo(lngFieldCounter).FieldName & _ Chr(34) & Chr(13) & Chr(10)Next

strCode = strCode & "Public Const g_cdm" & v_sPrimaryKey & _ " As String = " & Chr(34) & v_sPrimaryKey & "Equals" & _ Chr(34) & Chr(13) & Chr(10)CreateDeclarations = strCodeEnd Function

Public Function CreateErrorFunc()

Dim strCode As StringstrCode = "Public Function GetErrorText (ByVal v_lngErrorNumber As Long)" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo GetErrorText_Error" & Chr(13) & Chr(10)strCode = strCode & " GetErrorText = LoadResString(v_lngErrorNumber)" & Chr(13) & Chr(10)strCode = strCode & " Exit Function" & Chr(13) & Chr(10)strCode = strCode & "GetErrorText_Error:" & Chr(13) & Chr(10)strCode = strCode & " If Err.Number 0 Then" & Chr(13) & Chr(10)strCode = strCode & " GetErrorText =" & Chr(34) & _ "An unknown error has occurred, the error was not found" & _ Chr(34) & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10)CreateErrorFunc = strCode

End Function

VB Proj Man/Code Generator/BuildBottom.basAttribute VB_Name = "BuildBottom"Option Explicit

Public Function CreateDeclarations() As StringDim strCode As StringstrCode = strCode & " Private m_blnValidatingFieldChange As Boolean" & _ Chr(13) & Chr(10)strCode = strCode & " Private m_eEditMode As ADODB.EditModeEnum" & _ Chr(13) & Chr(10)strCode = strCode & " Private m_strErrorDetails As String" & Chr(13) & _ Chr(10)strCode = strCode & " Private m_blnIgnoreFieldChange As Boolean" & _ Chr(13) & Chr(10)strCode = strCode & " Private m_blnInFieldChange As Boolean" & _ Chr(13) & Chr(10)strCode = strCode & " Private m_avarAcceptableValuesTitle As Variant" & _ Chr(13) & Chr(10)strCode = strCode & " Private m_strManagedObjectDataMember As String" & _ Chr(13) & Chr(10)strCode = strCode & " Private WithEvents m_recManagedObjects As " & _ " ADODB.Recordset" & Chr(13) & Chr(10)strCode = strCode & " Public Event RefreshDataMember()" & Chr(13) & _ Chr(10)strCode = strCode & " Public Event EditInProgress(ByVal v_strEditMode)" & _ Chr(13) & Chr(10)CreateDeclarations = strCodeEnd Function

Public Function CreateInitialize() As StringDim strCode As String

strCode = " Private Sub Class_Initialize()" & Chr(13) & Chr(10)strCode = strCode & " m_blnValidatingFieldChange = False" & Chr(13) & Chr(10)strCode = strCode & " m_blnIgnoreFieldChange = False" & Chr(13) & Chr(10)strCode = strCode & " m_blnInFieldChange = False" & Chr(13) & Chr(10) & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo InitializeError" & Chr(13) & Chr(10)strCode = strCode & " m_eEditMode = adEditNone" & Chr(13) & Chr(10)strCode = strCode & " Set m_recManagedObjects = New ADODB.Recordset" & _Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "InitializeError:" & Chr(13) & Chr(10)strCode = strCode & " MsgBox " & Chr(34) & "Error In Class Initialize" & _ Chr(34) & Chr(13) & Chr(10)strCode = strCode & "End Sub"CreateInitialize = strCodeEnd Function

Public Function CreateTerminate()

Dim strCode As StringstrCode = strCode & "Private Sub Class_Terminate()" & Chr(13) & Chr(10)strCode = strCode & " If Not m_recManagedObjects Is Nothing Then" & Chr(13) & Chr(10)strCode = strCode & " With ItemsRecordset" & Chr(13) & Chr(10)strCode = strCode & " If .State = adStateOpen Then" & Chr(13) & Chr(10)strCode = strCode & " If Not .BOF And Not .EOF Then" & Chr(13) & Chr(10)strCode = strCode & " If .EditMode adEditNone Then" & Chr(13) & Chr(10)strCode = strCode & " .CancelUpdate" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " .Close" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " End With" & Chr(13) & Chr(10)strCode = strCode & " Set m_recManagedObjects = Nothing" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)CreateTerminate = strCodeEnd Function

Public Function CreateValidateFields(ByRef r_uFieldInfo() As _ FieldInformation) As StringDim strCode As StringDim lngFieldsCounter As LongDim strFieldNames() As String

CleanFields r_uFieldInfo, strFieldNames

strCode = "Friend Function ValidateFields(ByVal v_vFields As Variant, _" & _ Chr(13) & Chr(10)strCode = strCode & " ByVal v_recRecordset As ADODB.Recordset) " & _ " As Boolean" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo ValidateFieldsError" & Chr(13) & _ Chr(10)strCode = strCode & " m_blnValidatingFieldChange = True" & Chr(13) & _ Chr(10)strCode = strCode & " Select Case LCase(v_vFields(0).Name)" & Chr(13) & _ Chr(10)For lngFieldsCounter = 1 To UBound(r_uFieldInfo) strCode = strCode & " Case g_cstrField" & _ strFieldNames(lngFieldsCounter) & Chr(13) & Chr(10) strCode = strCode & " " & strFieldNames(lngFieldsCounter) & _ " = v_recRecordset.Fields(g_cstrField" & _ strFieldNames(lngFieldsCounter) & ")" & Chr(13) & Chr(10)NextstrCode = strCode & " Case Else" & Chr(13) & Chr(10)strCode = strCode & " ValidateFields = False" & Chr(13) & Chr(10)strCode = strCode & " End Select" & Chr(13) & Chr(10)strCode = strCode & " m_blnValidatingFieldChange = False" & Chr(13) & _ Chr(10)strCode = strCode & " ValidateFields = True" & Chr(13) & Chr(10)strCode = strCode & " Exit Function" & Chr(13) & Chr(10)strCode = strCode & "ValidateFieldsError:" & Chr(13) & Chr(10)strCode = strCode & " ValidateFields = False" & Chr(13) & Chr(10)strCode = strCode & " m_blnValidatingFieldChange = False" & Chr(13) & _ Chr(10)strCode = strCode & " Err.Clear" & Chr(13) & Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10)CreateValidateFields = strCodeEnd Function

Public Function CreateChangedField() As StringDim strCode As StringstrCode = strCode & "Private Sub " & _ "m_recManagedObjects_FieldChangeComplete(ByVal cFields As Long," & _ "ByVal Fields As Variant, ByVal pError As ADODB.Error," & _ "adStatus As ADODB.EventStatusEnum, " & _ "ByVal pRecordset As ADODB.Recordset)" & Chr(13) & Chr(10)

strCode = strCode & " On Error GoTo FieldChangeError" & Chr(13) & Chr(10)strCode = strCode & " If m_blnIgnoreFieldChange = True Then" & Chr(13) & _ Chr(10)strCode = strCode & " m_blnIgnoreFieldChange = False" & Chr(13) & _ Chr(10)strCode = strCode & " DataMemberChanged ItemsDataMember" & Chr(13) & _ Chr(10)strCode = strCode & " RaiseEvent RefreshDataMember" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " If m_blnInFieldChange = True Then" & Chr(13) & _ Chr(10)strCode = strCode & " m_blnInFieldChange = False" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " If m_recManagedObjects.RecordCount = 0 _" & _ Chr(13) & Chr(10)strCode = strCode & _" Or m_recManagedObjects.State adStateOpen Then" & _ Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " If EditMode = adEditDelete Then" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " If EditMode = adEditNone Then" & Chr(13) & Chr(10)strCode = strCode & " EditMode = adEditInProgress" & Chr(13) & Chr(10)strCode = strCode & " RaiseEvent EditInProgress(adEditInProgress)" & _ Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "If ValidateFields(Fields, pRecordset) = False Then" & _ Chr(13) & Chr(10)strCode = strCode & " m_blnInFieldChange = True" & Chr(13) & Chr(10)strCode = strCode & " m_recManagedObjects.Fields(Fields(0).Name).Value" & _ " = _ " & Chr(13) & Chr(10)strCode = strCode & _" pRecordset.Fields(Fields(0).Name).UnderlyingValue" & _ Chr(13) & Chr(10)

strCode = strCode & " m_blnInFieldChange = False" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " DataMemberChanged ItemsDataMember" & Chr(13) & _ Chr(10)strCode = strCode & " RaiseEvent RefreshDataMember" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "FieldChangeError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & "FieldChange " & Chr(34) & " & Err.Source, Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)CreateChangedField = strCode

End Function

Public Function CreateGetLet(ByRef r_uFieldInfo() As FieldInformation) As String

Dim strCode As StringDim lngFieldsCounter As LongDim strFieldNames() As String

CleanFields r_uFieldInfo, strFieldNames

For lngFieldsCounter = 1 To UBound(r_uFieldInfo)

strCode = strCode & "Public Property Get " & _ strFieldNames(lngFieldsCounter) & "() As " & _ r_uFieldInfo(lngFieldsCounter).DataType & Chr(13) & Chr(10) strCode = strCode & " On Error Resume Next" & Chr(13) & Chr(10) strCode = strCode & " " & strFieldNames(lngFieldsCounter) & _ "= ItemsRecordset.Fields(g_cstrField" & _ strFieldNames(lngFieldsCounter) & ")" & Chr(13) & Chr(10) strCode = strCode & " If Err.Number 0 Then" & Chr(13) & Chr(10) strCode = strCode & " If Err.Number 3265 Then" & Chr(13) & _ Chr(10) strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & _ strFieldNames(lngFieldsCounter) & "Get" & Chr(34) & _ ", Err.Description" & Chr(13) & Chr(10) strCode = strCode & " End If" & Chr(13) & Chr(10) strCode = strCode & " End If" & Chr(13) & Chr(10) strCode = strCode & "End Property" & Chr(13) & Chr(10) strCode = strCode & "Public Property Let " & _ strFieldNames(lngFieldsCounter) & "(ByVal v_strNew" & _ strFieldNames(lngFieldsCounter) & " As " & _ r_uFieldInfo(lngFieldsCounter).DataType & ")" & Chr(13) & Chr(10) strCode = strCode & " On Error GoTo " & _ strFieldNames(lngFieldsCounter) & "LetError" & Chr(13) & Chr(10) strCode = strCode & " If m_blnValidatingFieldChange = True Then" & _ Chr(13) & Chr(10) strCode = strCode & " Exit Property" & Chr(13) & Chr(10) strCode = strCode & " End If" & Chr(13) & Chr(10) strCode = strCode & " If m_eEditMode = adEditInProgress " & _ "Or m_eEditMode = adEditAdd Then" & Chr(13) & Chr(10) strCode = strCode & " m_blnIgnoreFieldChange = True" & Chr(13) & _ Chr(10) strCode = strCode & " ItemsRecordset.Fields(g_cstrField" & _ strFieldNames(lngFieldsCounter) & ") = v_strNew" & _ strFieldNames(lngFieldsCounter) & "" & Chr(13) & Chr(10) strCode = strCode & " ElseIf m_eEditMode = adEditNone Then" & _ Chr(13) & Chr(10) strCode = strCode & " Err.Raise 1001," & Chr(34) & _ strFieldNames(lngFieldsCounter) & " Let:" & Chr(34) & _ ", GetErrorText(errChangeFieldNoEdit)" & Chr(13) & Chr(10) strCode = strCode & " End If" & Chr(13) & Chr(10) strCode = strCode & " Exit Property" & Chr(13) & Chr(10) strCode = strCode & strFieldNames(lngFieldsCounter) & "LetError:" & _ Chr(13) & Chr(10) strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & _ strFieldNames(lngFieldsCounter) & " Let " & Chr(34) & _ " & Err.Source, Err.Description" & Chr(13) & Chr(10) strCode = strCode & "End Property" & Chr(13) & Chr(10)

NextCreateGetLet = strCodeEnd Function

Public Function CreateMiscProps(ByVal v_sTableName As String) As String

Dim strCode As StringstrCode = "Public Property Get EditMode() As ADODB.EditModeEnum" & _ Chr(13) & Chr(10)strCode = strCode & " EditMode = m_eEditMode" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)strCode = strCode & "Friend Property Let EditMode" & _ " (ByVal v_eNewEditMode As ADODB.EditModeEnum)" & Chr(13) & Chr(10)strCode = strCode & " m_eEditMode = v_eNewEditMode" & Chr(13) & Chr(10)strCode = strCode & " RaiseEvent EditInProgress(v_eNewEditMode)" & _ Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)strCode = strCode & "Friend Property Let ItemsDataMember(ByVal v_strNew" & _ v_sTableName & "DataMember As String)" & Chr(13) & Chr(10)strCode = strCode & " m_strManagedObjectDataMember = v_strNew" & _ v_sTableName & "DataMember" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)strCode = strCode & "Private Property Get ItemsDataMember() As String" & _ Chr(13) & Chr(10)strCode = strCode & " ItemsDataMember = m_strManagedObjectDataMember" & _ Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)strCode = strCode & "Friend Sub RefreshDataMember()" & Chr(13) & Chr(10)strCode = strCode & " DataMemberChanged ItemsDataMember" & Chr(13) & _ Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)strCode = strCode & "Friend Property Get ItemsRecordset() As " & _ " ADODB.Recordset" & Chr(13) & Chr(10)strCode = strCode & " Set ItemsRecordset = m_recManagedObjects" & _ Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)strCode = strCode & "Friend Property Set ItemsRecordset" & _ " (ByVal v_recNewRecordset As ADODB.Recordset)" & Chr(13) & Chr(10)strCode = strCode & " Set m_recManagedObjects = v_recNewRecordset" & _ Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)strCode = strCode & _ "Private Sub Class_GetDataMember" & _ " (DataMember As String, Data As Object)" & Chr(13) & Chr(10)strCode = strCode & " Set Data = m_recManagedObjects" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)CreateMiscProps = strCodeEnd Function

VB Proj Man/Code Generator/BuildMiddle.basAttribute VB_Name = "BuildMiddle"Option Explicit

Public Function CreateDeclarartions(ByRef r_TableInfo() As String, ByVal v_sTableName As String) As StringDim strCode As StringDim lngTableCounter As LongDim strTempTableName As String strCode = strCode & "Enum TableName" & Chr(13) & Chr(10)For lngTableCounter = 1 To UBound(r_TableInfo) strTempTableName = r_TableInfo(lngTableCounter) strCode = strCode & " e_" & r_TableInfo(lngTableCounter) & _ "=" & lngTableCounter - 1 & Chr(13) & Chr(10)NextstrCode = strCode & "End Enum" & Chr(13) & Chr(10)strCode = strCode & "Public Enum BOFActionType" & Chr(13) & Chr(10)strCode = strCode & " adMoveFirst = 0" & Chr(13) & Chr(10)strCode = strCode & " adStayBOF = 1" & Chr(13) & Chr(10)strCode = strCode & "End Enum" & Chr(13) & Chr(10)strCode = strCode & "Public Enum EOFActionType" & Chr(13) & Chr(10)strCode = strCode & " adMoveLast = 0" & Chr(13) & Chr(10)strCode = strCode & " adStayEOF = 1" & Chr(13) & Chr(10)strCode = strCode & " adAddNew = 2" & Chr(13) & Chr(10)strCode = strCode & "End Enum" & Chr(13) & Chr(10)strCode = strCode & "Private m_eRecordsetName As TableName" & Chr(13) & _ Chr(10)strCode = strCode & "Private m_strWhereClause As String" & Chr(13) & Chr(10)strCode = strCode & "Private m_strDataMember As String" & Chr(13) & Chr(10)strCode = strCode & "Private m_strPrimaryKey As String" & Chr(13) & Chr(10)strCode = strCode & "Private m_eBOFAction As BOFActionType" & Chr(13) & _ Chr(10)strCode = strCode & "Private m_eEOFAction As EOFActionType" & Chr(13) & _ Chr(10)strCode = strCode & "Private m_strUserName As String" & Chr(13) & Chr(10)strCode = strCode & "Private m_strPassword As String" & Chr(13) & Chr(10)strCode = strCode & "Private m_eEditMode As ADODB.EditModeEnum" & _ Chr(13) & Chr(10)strCode = strCode & "Private WithEvents m_objManagedObject As cls" & _ v_sTableName & Chr(13) & Chr(10)strCode = strCode & "Public Event ChangeManagedObjects()" & Chr(13) & _ Chr(10)strCode = strCode & "Const m_def_BOFAction = BOFActionType.adMoveFirst" & _ Chr(13) & Chr(10)strCode = strCode & "Const m_def_EOFAction = EOFActionType.adMoveLast" & _ Chr(13) & Chr(10)strCode = strCode & "Const m_def_UserName = " & Chr(34) & Chr(34) & _ Chr(13) & Chr(10)strCode = strCode & "Const m_def_Password = " & Chr(34) & Chr(34) & _ Chr(13) & Chr(10)strCode = strCode & "Private m_objDataSpace As RDS.DataSpace" & _ Chr(13) & Chr(10)strCode = strCode & "Private m_objProxy 'As clsServer" & Chr(13) & Chr(10)CreateDeclarartions = strCodeEnd Function

Public Function CreateInitTerm(ByVal v_sTableName As String) As StringDim strCode As StringstrCode = strCode & "Private Sub Class_Initialize()" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo IntitializeError" & Chr(13) & Chr(10)strCode = strCode & " Set m_objManagedObject = New cls" & v_sTableName & _ Chr(13) & Chr(10)strCode = strCode & " GetProxy" & Chr(13) & Chr(10)strCode = strCode & " 'Set m_objProxy = New clsServer" & Chr(13) & Chr(10)strCode = strCode & " m_eBOFAction = m_def_BOFAction" & Chr(13) & Chr(10)strCode = strCode & " m_eEOFAction = m_def_EOFAction" & Chr(13) & Chr(10)strCode = strCode & " m_strUserName = m_def_UserName" & Chr(13) & Chr(10)strCode = strCode & " m_strPassword = m_def_Password" & Chr(13) & Chr(10)strCode = strCode & " m_eEditMode = adEditNone" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "IntitializeError:" & Chr(13) & Chr(10)strCode = strCode & " MsgBox " & Chr(34) & _ "Collection Managing Class cannot be initialized" & Chr(34) & _ Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)strCode = strCode & "Private Sub Class_Terminate()" & Chr(13) & Chr(10)strCode = strCode & " If Not m_objManagedObject Is Nothing Then" & _ Chr(13) & Chr(10)strCode = strCode & " Set m_objManagedObject = Nothing" & Chr(13) & _ Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)CreateInitTerm = strCodeEnd Function

Public Function CreateGeneral(ByVal v_sTableName As String, _ ByVal v_bPrimKeyNum As Boolean) As StringDim strCode As StringstrCode = "Private Sub Class_GetDataMember " & _ "(DataMember As String, Data As Object)" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo GetDataMemberError" & Chr(13) & Chr(10)strCode = strCode & " If ItemsDataMember DataMember Then" & _ Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Set Data = m_objManagedObject.ItemsRecordset" & _ Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "GetDataMemberError:" & Chr(13) & Chr(10)strCode = strCode & " Set Data = Nothing" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Sub GetProxy()" & Chr(13) & Chr(10)strCode = strCode & " Set m_objDataSpace = New RDS.DataSpace" & _ Chr(13) & Chr(10)strCode = strCode & " m_objDataSpace.InternetTimeout = 30000" & _ Chr(13) & Chr(10)strCode = strCode & " Set m_objProxy = m_objDataSpace.CreateObject _" & _ Chr(13) & Chr(10)strCode = strCode & " (" & Chr(34) & "prjServer.clsServer" & _ Chr(34) & ", " & Chr(34) & Chr(34) & ")" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Friend Function SetProxyInformation " & _ " (ByVal v_eRecordsetName As TableName, _" & Chr(13) & Chr(10)strCode = strCode & " ByVal v_strWhereClause As String, " & _ " ByVal v_strPrimaryKey As String, _" & Chr(13) & Chr(10)strCode = strCode & " ByVal v_eDataMember As String)" & Chr(13) & _ Chr(10)strCode = strCode & " m_eRecordsetName = v_eRecordsetName" & _ Chr(13) & Chr(10)strCode = strCode & " m_strWhereClause = v_strWhereClause" & _ Chr(13) & Chr(10)strCode = strCode & " m_strPrimaryKey = v_strPrimaryKey" & _ Chr(13) & Chr(10)strCode = strCode & " m_strDataMember = v_eDataMember" & _ Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.ItemsDataMember = " & _ "v_eDataMember" & Chr(13) & Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Friend Property Get ItemsDataMember() As String" & _ Chr(13) & Chr(10)strCode = strCode & " ItemsDataMember = m_strDataMember" & _ Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)strCode = strCode & "Private Property Get PrimaryKey() As String" & _ Chr(13) & Chr(10)strCode = strCode & " PrimaryKey = m_strPrimaryKey" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)strCode = strCode & "Private Property Get RecordsetName() As TableName" & _ Chr(13) & Chr(10)strCode = strCode & " RecordsetName = m_eRecordsetName" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Private Property Get WhereClause() As String" & _ Chr(13) & Chr(10)strCode = strCode & " WhereClause = m_strWhereClause" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Property Get Item() As cls" & v_sTableName & _ Chr(13) & Chr(10)strCode = strCode & " Set Item = m_objManagedObject" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Property Get ItemCount() As Long" & Chr(13) & _ Chr(10)strCode = strCode & " ItemCount =" & _ " m_objManagedObject.ItemsRecordset.RecordCount" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Private Sub UpdateManagedObjects()" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo UpdateManagedObjectsError" & _ Chr(13) & Chr(10)strCode = strCode & " Set m_objManagedObject.ItemsRecordset = _" & _ Chr(13) & Chr(10)strCode = strCode & " m_objProxy.Return" & v_sTableName & _ "RecordSet(UserName, Password, WhereClause)" & Chr(13) & Chr(10)strCode = strCode & " DataMemberChanged ItemsDataMember" & Chr(13) & _ Chr(10)strCode = strCode & " m_objManagedObject.RefreshDataMember" & Chr(13) & _ Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)strCode = strCode & "UpdateManagedObjectsError:" & Chr(13) & Chr(10)strCode = strCode & " MsgBox Err.Description & Err.Source" & Chr(13) & _ Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Friend Property Get ItemsRecordset() As " & _ "ADODB.Recordset" & Chr(13) & Chr(10)strCode = strCode & " Set ItemsRecordset = " & _ "m_objManagedObject.ItemsRecordset" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Property Get EditMode() As ADODB.EditModeEnum" & _ Chr(13) & Chr(10)strCode = strCode & " EditMode = m_eEditMode" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Friend Property Let EditMode" & _ "(ByVal v_eNewEditMode As ADODB.EditModeEnum)" & Chr(13) & Chr(10)strCode = strCode & " m_eEditMode = v_eNewEditMode" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.EditMode " & _ " v_eNewEditMode Then" & Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.EditMode = v_eNewEditMode" & _ Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Sub Refresh()" & Chr(13) & Chr(10)If v_bPrimKeyNum Then strCode = strCode & " Dim strPrimaryKeyValue As Long" & Chr(13) & _ Chr(10)Else strCode = strCode & " Dim strPrimaryKeyValue As String" & Chr(13) & _ Chr(10)End IfstrCode = strCode & " If m_objManagedObject.ItemsRecordset.State = " & _ "adStateOpen Then" & Chr(13) & Chr(10)strCode = strCode & " If Not m_objManagedObject.ItemsRecordset.BOF " & _ " And _" & Chr(13) & Chr(10)strCode = strCode & " Not m_objManagedObject.ItemsRecordset.EOF " & _ " And _" & Chr(13) & Chr(10)strCode = strCode & " Not " & _ "IsNull(m_objManagedObject.ItemsRecordset.Fields(PrimaryKey)) Then" & _ Chr(13) & Chr(10)strCode = strCode & " strPrimaryKeyValue = _" & _ Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.ItemsRecordset.Fields " & _ " (PrimaryKey)" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " UpdateManagedObjects" & Chr(13) & Chr(10)

If v_bPrimKeyNum Then strCode = strCode & " If strPrimaryKeyValue 0 Then" & Chr(13) & _ Chr(10) strCode = strCode & " m_objManagedObject.ItemsRecordset.Find " & _ "PrimaryKey & " & Chr(34) & "=" & Chr(34) & " & _" & _ Chr(13) & Chr(10) & _ "strPrimaryKeyValue " & ", , , 1" & Chr(13) & Chr(10)Else strCode = strCode & " If strPrimaryKeyValue " & Chr(34) & _ Chr(34) & " Then" & Chr(13) & Chr(10) strCode = strCode & " m_objManagedObject.ItemsRecordset.Find " & _ " PrimaryKey & " & Chr(34) & "='" & Chr(34) & " & _" & Chr(13) & _ Chr(10) & "strPrimaryKeyValue & " & Chr(34) & "'" & _ Chr(34) & ", , , 1" & Chr(13) & Chr(10)End IfstrCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)

strCode = strCode & "Public Sub Update()" & Chr(13) & Chr(10)If v_bPrimKeyNum Then strCode = strCode & " Dim strPrimaryKeyValue As Long" & Chr(13) & _ Chr(10)Else strCode = strCode & " Dim strPrimaryKeyValue As String" & Chr(13) & _ Chr(10)End If

strCode = strCode & " On Error GoTo UpdateError" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset.State = " & _ "adStateOpen And _" & Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.ItemsRecordset.EditMode " & _ " adEditDelete And (Not " & _ "IsNull(m_objManagedObject.ItemsRecordset.Fields(PrimaryKey))) Then" & _ Chr(13) & Chr(10)strCode = strCode & " If " & _ " m_objManagedObject.ItemsRecordset.RecordCount 0 Then" & _ Chr(13) & Chr(10)strCode = strCode & " strPrimaryKeyValue = _" & Chr(13) & _ Chr(10)strCode = strCode & _ " m_objManagedObject.ItemsRecordset.Fields" & _ " (PrimaryKey)" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " If EditMode adEditNone Then" & Chr(13) & Chr(10)strCode = strCode & " Set m_objManagedObject.ItemsRecordset = " & _ "m_objProxy.UpdateRecordset(UserName, _" & Chr(13) & Chr(10)strCode = strCode & " Password, m_objManagedObject.ItemsRecordset," & _ "m_eRecordsetName, _" & Chr(13) & Chr(10)strCode = strCode & " WhereClause)" & Chr(13) & Chr(10)strCode = strCode & " EditMode = adEditNone" & Chr(13) & Chr(10)strCode = strCode & " RaiseEvent ChangeManagedObjects" & Chr(13) & _ Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)

If v_bPrimKeyNum Then strCode = strCode & " If strPrimaryKeyValue 0 Then" & Chr(13) & _ Chr(10) strCode = strCode & " m_objManagedObject.ItemsRecordset.Find " & _ " PrimaryKey & " & Chr(34) & "=" & Chr(34) & " & _" & Chr(13) & _ Chr(10) & "strPrimaryKeyValue " & ", , , 1" & Chr(13) & Chr(10)Else strCode = strCode & " If strPrimaryKeyValue " & Chr(34) & _ Chr(34) & " Then" & Chr(13) & Chr(10) strCode = strCode & " m_objManagedObject.ItemsRecordset.Find " & _ "PrimaryKey & " & Chr(34) & "='" & Chr(34) & " & _" & _ Chr(13) & Chr(10) & "strPrimaryKeyValue & " & Chr(34) & "'" & _ "Chr(34) & , , , 1" & Chr(13) & Chr(10)End IfstrCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "UpdateError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & "Update: " & _ Chr(34) & " & Err.Source, Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Function Find(ByVal v_strPrimaryKey As " & _ "String)" & Chr(13) & Chr(10)If v_bPrimKeyNum Then strCode = strCode & " Dim strPrimaryKeyValue As Long" & Chr(13) & _ Chr(10) strCode = strCode & " If v_strPrimaryKey = 0 Then" & Chr(13) & Chr(10)Else strCode = strCode & " Dim strPrimaryKeyValue As String" & Chr(13) & _ Chr(10) strCode = strCode & " If v_strPrimaryKey = " & Chr(34) & Chr(34) & _ "Then" & Chr(13) & Chr(10)End If

strCode = strCode & " Exit Function" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)If v_bPrimKeyNum Then strCode = strCode & " If InStr(v_strPrimaryKey, " & Chr(34) & "'" & _ Chr(34) & ") > 0 Then" & Chr(13) & Chr(10) strCode = strCode & " v_strPrimaryKey = " & _ "Mid(v_strPrimaryKey, 1, InStr(v_strPrimaryKey, " & Chr(34) & "'" & _ Chr(34) & ") - 1)" & Chr(13) & Chr(10) strCode = strCode & " Else" & Chr(13) & Chr(10) strCode = strCode & " v_strPrimaryKey = v_strPrimaryKey" & _ Chr(13) & Chr(10) strCode = strCode & " End If" & Chr(13) & Chr(10)End IfIf v_bPrimKeyNum Then strCode = strCode & " ItemsRecordset.Find PrimaryKey & " & _ Chr(34) & "=" & Chr(34) & " & _" & Chr(13) & Chr(10) & _ "v_strPrimaryKey " & ", , , 1" & Chr(13) & Chr(10)Else strCode = strCode & " ItemsRecordset.Find PrimaryKey & " & Chr(34) & "='" & Chr(34) & " & _" & Chr(13) & Chr(10) & _ "v_strPrimaryKey & " & Chr(34) & "'" & _ Chr(34) & ", , , 1" & Chr(13) & Chr(10)End If

strCode = strCode & " Refresh" & Chr(13) & Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10)CreateGeneral = strCodeEnd Function

Public Function CreateDataMethods() As String

Dim strCode As String

strCode = "Public Sub Edit()" & Chr(13) & Chr(10)strCode = strCode & " If EditMode = adEditNone Then" & Chr(13) & Chr(10)strCode = strCode & " EditMode = adEditInProgress" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10) strCode = strCode & "Public Sub Delete()" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo DeleteError" & Chr(13) & Chr(10)strCode = strCode & " If EditMode = adEditNone Then" & Chr(13) & Chr(10)strCode = strCode & " m_objProxy.UpdateRecordset UserName, " & _ " Password, _" & Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.ItemsRecordset, " & _ " m_eRecordsetName, WhereClause, True" & Chr(13) & Chr(10)strCode = strCode & " RaiseEvent ChangeManagedObjects" & Chr(13) & _ Chr(10)strCode = strCode & " Else" & Chr(13) & Chr(10)strCode = strCode & " GetErrorText " & Chr(34) & _ "CanNotDeleteDuringEdit/AddNew" & Chr(34) & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "DeleteError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & "Delete " & _ Chr(34) & "& Err.Source, Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Sub AddNew()" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo AddNewError" & Chr(13) & Chr(10)strCode = strCode & " If EditMode = adEditNone Then" & Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.ItemsRecordset.AddNew" & _ Chr(13) & Chr(10)strCode = strCode & " EditMode = adEditAdd" & Chr(13) & Chr(10)strCode = strCode & " Else" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "AddNewError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & "AddNew " & _ Chr(34) & "& Err.Source, Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)

strCode = strCode & "Public Sub Cancel()" & Chr(13) & Chr(10)strCode = strCode & " If EditMode = adEditAdd Or EditMode = " & _ "adEditInProgress Then" & Chr(13) & Chr(10)strCode = strCode & " ItemsRecordset.CancelUpdate" & Chr(13) & Chr(10)strCode = strCode & " EditMode = adEditNone" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)

strCode = strCode & "Public Property Get RecordCount() As Long" & _ Chr(13) & Chr(10)strCode = strCode & " RecordCount = m_objManagedObject.ItemsRecordset.RecordCount" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)

strCode = strCode & "Public Sub MoveFirst()" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo MoveFirstError" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset Is Nothing " & _ "Then" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset.RecordCount " & _ "> 0 Then" & Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.ItemsRecordset.MoveFirst" & _ Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "MoveFirstError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & "Move First " & _ Chr(34) & "& Err.Source, Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Sub MoveLast()" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo MoveLastError" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset Is Nothing " & _ "Then" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset.RecordCount " & _ "> 0 Then" & Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.ItemsRecordset.MoveLast" & _ Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "MoveLastError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & "Move Last " & _ Chr(34) & "& Err.Source, Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Sub MoveNext()" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo MoveNextError" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset " & _ "Is Nothing Then" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset.EOF = False " & _ " Then" & Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.ItemsRecordset.MoveNext" & _ Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset.EOF = " & _ "True Then" & Chr(13) & Chr(10)strCode = strCode & " Select Case EOFAction" & Chr(13) & Chr(10)strCode = strCode & " Case EOFActionType.adAddNew" & Chr(13) & _ Chr(10)strCode = strCode & " m_objManagedObject.ItemsRecordset.AddNew" & _ Chr(13) & Chr(10)strCode = strCode & " Case EOFActionType.adMoveLast" & Chr(13) & _ Chr(10)strCode = strCode & _ " m_objManagedObject.ItemsRecordset.MoveLast" & Chr(13) & _ Chr(10)strCode = strCode & " Case EOFActionType.adStayEOF" & Chr(13) & _ Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " Case Else" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End Select" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "MoveNextError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & "Move Next " & _ Chr(34) & " & Err.Source, Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)

strCode = strCode & "Public Sub MovePrevious()" & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo MovePreviousError" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset Is Nothing " & _ "Then Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " If m_objManagedObject.ItemsRecordset.BOF Then" & _ Chr(13) & Chr(10)strCode = strCode & " Select Case BOFAction" & Chr(13) & Chr(10)strCode = strCode & " Case BOFActionType.adMoveFirst" & _ Chr(13) & Chr(10)strCode = strCode & _ " m_objManagedObject.ItemsRecordset.MoveFirst" & _ Chr(13) & Chr(10)strCode = strCode & " Case BOFActionType.adStayBOF" & _ Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " Case Else" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & " End Select" & Chr(13) & Chr(10)strCode = strCode & " Else" & Chr(13) & Chr(10)strCode = strCode & " m_objManagedObject.ItemsRecordset.MovePrevious" & _ Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "MovePreviousError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & _ "Move Previous Error" & Chr(34) & "& Err.Source, _" & _ Chr(13) & Chr(10)strCode = strCode & " Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)

strCode = strCode & "Public Property Get UserName() As String" & _ Chr(13) & Chr(10)strCode = strCode & " UserName = m_strUserName" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Property Let UserName" & _ " (ByVal New_strUserName As String)" & Chr(13) & Chr(10)strCode = strCode & " m_strUserName = New_strUserName" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Property Get Password() As String" & _ Chr(13) & Chr(10)strCode = strCode & " Password = m_strPassword" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Property Let Password " & _ " (ByVal New_strPassword As String)" & Chr(13) & Chr(10)strCode = strCode & " m_strPassword = New_strPassword" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)

strCode = strCode & "Public Property Get BOFAction() As BOFActionType" & _ Chr(13) & Chr(10)strCode = strCode & " BOFAction = m_eBOFAction" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)

strCode = strCode & "Public Property Let BOFAction" & _ " (ByVal New_BOFAction As BOFActionType)" & Chr(13) & Chr(10)strCode = strCode & " m_eBOFAction = New_BOFAction" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Property Get EOFAction() As EOFActionType" & _ Chr(13) & Chr(10)strCode = strCode & " EOFAction = m_eEOFAction" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Public Property Let EOFAction" & _ " (ByVal New_EOFAction As EOFActionType)" & Chr(13) & Chr(10)strCode = strCode & " m_eEOFAction = New_EOFAction" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

strCode = strCode & "Private Sub m_objManagedObject_EditInProgress" & _ " (ByVal v_strEditMode As Variant)" & Chr(13) & Chr(10)strCode = strCode & " EditMode = v_strEditMode" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)

strCode = strCode & "Private Sub m_objManagedObject_RefreshDataMember()" & _ Chr(13) & Chr(10)strCode = strCode & " DataMemberChanged ItemsDataMember" & _ Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)CreateDataMethods = strCode

End Function

VB Proj Man/Code Generator/BuildServer.basAttribute VB_Name = "BuildServer"Option Explicit

Public Function CreateServer(ByRef r_TableInfo() As String, _ ByRef r_Tables() As TableInformation) As StringDim strCode As StringDim lngTableCounter As LongDim strTempTableName As StringDim lngFieldCounter As LongDim lngQueryKeyCounter As LongDim strTableName As String

strCode = strCode & "Enum TableName" & Chr(13) & Chr(10)For lngTableCounter = 1 To UBound(r_TableInfo) strCode = strCode & " e_" & r_TableInfo(lngTableCounter) & _ "=" & lngTableCounter - 1 & Chr(13) & Chr(10)NextstrCode = strCode & "End Enum" & Chr(13) & Chr(10)For lngTableCounter = 1 To UBound(r_TableInfo) Dim strCleanFields() As String CleanFields r_Tables(lngTableCounter).FieldInfo, strCleanFields Dim strFields As String strFields = "" For lngFieldCounter = 1 To UBound(r_Tables(lngTableCounter).FieldInfo) If lngFieldCounter = 1 Then strFields = " [" & _ r_Tables(lngTableCounter).FieldInfo(lngFieldCounter).FieldName & "]" Else strFields = strFields & ",[" & _ r_Tables(lngTableCounter).FieldInfo(lngFieldCounter).FieldName & "]" End If Next strCode = strCode & " Private Const m_cstr" & _ r_TableInfo(lngTableCounter) & "Query =" & Chr(34) & "Select " & _ strFields & Chr(34) & " & _" & Chr(13) & Chr(10) strCode = strCode & Chr(34) & " From " & _ r_Tables(lngTableCounter).TableName & Chr(34) & Chr(13) & Chr(10) strTableName = r_Tables(lngTableCounter).TableName strCode = strCode & " Private Const m_cstr" & _ r_TableInfo(lngTableCounter) & _ r_Tables(lngTableCounter).PrimaryKey & " As String = " & Chr(34) & _ r_Tables(lngTableCounter).PrimaryKey & Chr(34) & Chr(13) & Chr(10)Next

strCode = strCode & " Private Const m_cstrDatabasePath As String = " & _ Chr(34) & _ "C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB" & Chr(34) & _ Chr(13) & Chr(10)strCode = strCode & " Private m_objADOConnection As ADODB.Connection" & _ Chr(13) & Chr(10)strCode = strCode & " Private m_strErrorDetails As String" & Chr(13) & _ Chr(10)strCode = strCode & " Private m_strQueryString As String" & Chr(13) & _ Chr(10)strCode = strCode & " Private m_objContext As ObjectContext" & Chr(13) & _ Chr(10)strCode = strCode & " Implements ObjectControl" & Chr(13) & Chr(10)strCode = strCode & "Private Sub ObjectControl_Activate()" & Chr(13) & _ Chr(10)strCode = strCode & " Set m_objContext = GetObjectContext" & Chr(13) & _ Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)strCode = strCode & _ "Private Function ObjectControl_CanBePooled() As Boolean" & _ Chr(13) & Chr(10)strCode = strCode & " ObjectControl_CanBePooled = False" & Chr(13) & _ Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10)strCode = strCode & "Private Sub ObjectControl_Deactivate()" & Chr(13) & _ Chr(10)strCode = strCode & " Set m_objADOConnection = Nothing" & Chr(13) & Chr(10)strCode = strCode & " Set m_objContext = Nothing" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)strCode = strCode & _ "Private Function CreateInstance(ProgID As String) As Object" & _ Chr(13) & Chr(10)strCode = strCode & " On Error GoTo CreateInstanceError" & Chr(13) & _ Chr(10)strCode = strCode & " If Not m_objContext Is Nothing Then" & Chr(13) & _ Chr(10)strCode = strCode & _ " Set CreateInstance = m_objContext.CreateInstance(ProgID)" & _ Chr(13) & Chr(10)strCode = strCode & " Else" & Chr(13) & Chr(10)strCode = strCode & " Select Case ProgID" & Chr(13) & Chr(10)strCode = strCode & " Case " & Chr(34) & "ADODB.Connection" & _ Chr(34) & Chr(13) & Chr(10)strCode = strCode & " Set CreateInstance = New ADODB.Connection" & _ Chr(13) & Chr(10)strCode = strCode & " Case " & Chr(34) & "ADODB.Recordset" & Chr(34) & _ Chr(13) & Chr(10)strCode = strCode & " Set CreateInstance = New ADODB.Recordset" & _ Chr(13) & Chr(10)strCode = strCode & " End Select" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Exit Function" & Chr(13) & Chr(10)strCode = strCode & "CreateInstanceError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, Err.Source & " & Chr(34) & _ "CreateInstance" & Chr(34) & ", Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10)strCode = strCode & "Public Sub SetComplete()" & Chr(13) & Chr(10)strCode = strCode & " If Not m_objContext Is Nothing Then" & Chr(13) & _ Chr(10)strCode = strCode & " m_objContext.SetComplete" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)strCode = strCode & "Public Sub SetAbort()" & Chr(13) & Chr(10)strCode = strCode & " If Not m_objContext Is Nothing Then" & Chr(13) & _ Chr(10)strCode = strCode & " m_objContext.SetAbort" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)strCode = strCode & _ "Private Sub SetADOConnection(ByVal v_strUserID As String, _" & _ Chr(13) & Chr(10)strCode = strCode & " ByVal v_strPassword As String)" & _ Chr(13) & Chr(10)strCode = strCode & " On Error GoTo SetADOConnectionError" & Chr(13) & _ Chr(10)strCode = strCode & " Set m_objADOConnection = CreateInstance(" & _ Chr(34) & "ADODB.Connection" & Chr(34) & ")" & Chr(13) & Chr(10)strCode = strCode & " With m_objADOConnection" & Chr(13) & Chr(10)strCode = strCode & " .CursorLocation = adUseClient" & Chr(13) & Chr(10)strCode = strCode & " .ConnectionString = " & Chr(34) & _ "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;" & _ Chr(34) & " & _ " & Chr(13) & Chr(10)strCode = strCode & " " & Chr(34) & "Data Source=" & Chr(34) & " & " & _ "m_cstrDatabasePath" & Chr(13) & Chr(10)strCode = strCode & " .Open" & Chr(13) & Chr(10)strCode = strCode & " End With" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "SetADOConnectionError:" & Chr(13) & Chr(10)strCode = strCode & " Dim lngErrorCounter As Long" & Chr(13) & Chr(10)strCode = strCode & " Dim strErrors As String" & Chr(13) & Chr(10)strCode = strCode & " strErrors = Err.Number & " & Chr(34) & ": " & _ Chr(34) & " & Err.Description" & Chr(13) & Chr(10)strCode = strCode & " If m_objADOConnection.Errors.Count > 0 Then" & _ Chr(13) & Chr(10)strCode = strCode & _ " For lngErrorCounter = 0 To m_objADOConnection.Errors.Count - 1" & _ Chr(13) & Chr(10)strCode = strCode & " strErrors = strErrors & _" & Chr(13) & Chr(10)strCode = strCode & _ " m_objADOConnection.Errors(lngErrorCounter).Number & _" & _ Chr(13) & Chr(10)strCode = strCode & " " & Chr(34) & ": " & Chr(34) & " & " & _ "m_objADOConnection.Errors(lngErrorCounter).Description & vbCrLf" & _ Chr(13) & Chr(10)strCode = strCode & " Next lngErrorCounter" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise 2000 + vbObjectError, " & Chr(34) & _ "SetADOConnection " & Chr(34) & " & Err.Source, strErrors" & _ Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)strCode = strCode & _ "Private Function GetADOConnection() As ADODB.Connection" & _ Chr(13) & Chr(10)strCode = strCode & " If m_objADOConnection Is Nothing Then" & _ Chr(13) & Chr(10)strCode = strCode & " Err.Raise 2001, " & Chr(34) & _ "GetADOConnection" & Chr(34) & ", _" & Chr(13) & Chr(10)strCode = strCode & " " & Chr(34) & _ "Trying to Get Connection prior to setting it" & Chr(34) & Chr(13) & _ Chr(10)strCode = strCode & " Else" & Chr(13) & Chr(10)strCode = strCode & " Set GetADOConnection = m_objADOConnection" & _ Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10)strCode = strCode & "Private Sub CloseADOConnection()" & Chr(13) & Chr(10)strCode = strCode & " With GetADOConnection" & Chr(13) & Chr(10)strCode = strCode & " If .State = adStateOpen Then" & Chr(13) & Chr(10)strCode = strCode & " .Close" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " End With" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)strCode = strCode & _ "Public Function ValidUserIDPassword(ByVal v_strUserID As String, _" & _ Chr(13) & Chr(10)strCode = strCode & _ " ByVal v_strPassword As String, Optional ByRef r_strErrorDetails" & _ " As String _" & Chr(13) & Chr(10)strCode = strCode & " = " & Chr(34) & "Empty" & Chr(34) & ") As Boolean" _ & Chr(13) & Chr(10)strCode = strCode & " On Error GoTo ValidUserIDPasswordError" & Chr(13) & _ Chr(10)strCode = strCode & " SetADOConnection v_strUserID, v_strPassword" & _ Chr(13) & Chr(10)strCode = strCode & " ValidUserIDPassword = True" & Chr(13) & Chr(10)strCode = strCode & " SetComplete" & Chr(13) & Chr(10)strCode = strCode & " Exit Function" & Chr(13) & Chr(10)strCode = strCode & "ValidUserIDPasswordError:" & Chr(13) & Chr(10)strCode = strCode & " If r_strErrorDetails " & Chr(34) & "Empty" & _ Chr(34) & "Then" & Chr(13) & Chr(10)strCode = strCode & " r_strErrorDetails = " & _ Chr(34) & "Error Details:" & Chr(34) & " & " & _ "Err.Description & vbCrLf & _" & Chr(13) & Chr(10)strCode = strCode & " " & Chr(34) & "Error Number:" & _ Chr(34) & " & " & "Err.Number & vbCrLf & " & Chr(34) & _ "Error Source: " & Chr(34) & " & _" & Chr(13) & Chr(10)strCode = strCode & " " & Chr(34) & "ValidUserIDPassword " & _ Chr(34) & " & Err.Source" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " SetAbort" & Chr(13) & Chr(10)strCode = strCode & " ValidUserIDPassword = False" & Chr(13) & Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10)strCode = strCode & "Private Sub GetRecordSet(ByRef r_recRecordset As " & _ "ADODB.Recordset, _" & Chr(13) & Chr(10)strCode = strCode & " ByVal v_strSource)" & Chr(13) & _ Chr(10)strCode = strCode & " On Error GoTo GetRecordSetError" & Chr(13) & Chr(10)strCode = strCode & " Set r_recRecordset = New ADODB.Recordset" & _ Chr(13) & Chr(10)strCode = strCode & " r_recRecordset.CursorLocation = adUseClient" & _ Chr(13) & Chr(10)strCode = strCode & " r_recRecordset.Open _" & Chr(13) & Chr(10)strCode = strCode & " v_strSource , GetADOConnection, adOpenStatic, " & _ " adLockOptimistic" & Chr(13) & Chr(10)strCode = strCode & " Exit Sub" & Chr(13) & Chr(10)strCode = strCode & "GetRecordSetError:" & Chr(13) & Chr(10)strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & "ValidUserID" & _ Chr(34) & " & Err.Source, Err.Description" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)For lngTableCounter = 1 To UBound(r_TableInfo) strCode = strCode & "Public Function Return" & _ r_TableInfo(lngTableCounter) & _ "RecordSet(ByVal v_strUserID As String, ByVal _" & Chr(13) & Chr(10) strCode = strCode & _ " v_strPassword As String, Optional ByVal v_strParameter As String)" & _ " As _" & Chr(13) & Chr(10) strCode = strCode & " ADODB.Recordset" & Chr(13) & Chr(10) strCode = strCode & " Dim rec" & r_TableInfo(lngTableCounter) & _ " As ADODB.Recordset" & Chr(13) & Chr(10) strCode = strCode & " On Error GoTo Return" & _ r_TableInfo(lngTableCounter) & "RecordSetError" & Chr(13) & Chr(10) strCode = strCode & " SetADOConnection v_strUserID, v_strPassword" & _ Chr(13) & Chr(10) strCode = strCode & " GetRecordSet rec" & _ r_TableInfo(lngTableCounter) & ", m_cstr" & _ r_TableInfo(lngTableCounter) & "Query & v_strParameter" & _ Chr(13) & Chr(10) strCode = strCode & " Set Return" & r_TableInfo(lngTableCounter) & _ "RecordSet = rec" & r_TableInfo(lngTableCounter) & Chr(13) & Chr(10) strCode = strCode & " Set rec" & r_TableInfo(lngTableCounter) & _ ".ActiveConnection = Nothing" & Chr(13) & Chr(10) strCode = strCode & " SetComplete" & Chr(13) & Chr(10) strCode = strCode & " CloseADOConnection" & Chr(13) & Chr(10) strCode = strCode & " Set rec" & r_TableInfo(lngTableCounter) & _ " = Nothing" & Chr(13) & Chr(10) strCode = strCode & " Exit Function" & Chr(13) & Chr(10) strCode = strCode & "Return" & r_TableInfo(lngTableCounter) & _ "RecordSetError:" & Chr(13) & Chr(10) strCode = strCode & " CloseADOConnection" & Chr(13) & Chr(10) strCode = strCode & " SetAbort" & Chr(13) & Chr(10) strCode = strCode & " Err.Raise Err.Number, " & Chr(34) & _ " Return" & r_TableInfo(lngTableCounter) & Chr(34) & " " & _ " , Err.Source " & " & _" & Chr(13) & Chr(10) strCode = strCode & " m_strErrorDetails" & Chr(13) & Chr(10) strCode = strCode & " End Function" & Chr(13) & Chr(10)

strCode = strCode & "Private Function Update" & _ r_TableInfo(lngTableCounter) & _ "RS(ByVal v_recClientRecordSet As _" & Chr(13) & Chr(10) strCode = strCode & _ " ADODB.Recordset, Optional ByVal v_bolDelete " & _ " As Boolean = False) As ADODB.Recordset" & Chr(13) & Chr(10) strCode = strCode & " Dim rec" & r_TableInfo(lngTableCounter) & _ " As ADODB.Recordset" & Chr(13) & Chr(10) strCode = strCode & " Dim lngFieldCounter As Long" & Chr(13) & Chr(10) strCode = strCode & " Dim lngRowCounter As Long" & Chr(13) & Chr(10) strCode = strCode & " On Error GoTo Update" & _ r_TableInfo(lngTableCounter) & "RSError" & Chr(13) & Chr(10) strCode = strCode & _ " If v_recClientRecordSet.EditMode = adEditAdd Then" & Chr(13) & _ Chr(10) strCode = strCode & " Set rec" & r_TableInfo(lngTableCounter) & _ " = CreateInstance(" & Chr(34) & "ADODB.Recordset" & Chr(34) & _ ")" & Chr(13) & Chr(10) strCode = strCode & " With rec" & r_TableInfo(lngTableCounter) & _ "" & Chr(13) & Chr(10) strTableName = r_Tables(lngTableCounter).TableName

strCode = strCode & " .Source = m_cstr" & _ r_TableInfo(lngTableCounter) & "Query & " & Chr(34) & " Where " & _ Chr(34) & " & m_cstr" & r_TableInfo(lngTableCounter) & _ r_Tables(lngTableCounter).PrimaryKey & " & " & Chr(34) & " = " & _ Chr(34) & " & _ " & Chr(13) & Chr(10) strCode = strCode & " 0" & Chr(13) & Chr(10) strCode = strCode & " .ActiveConnection = GetADOConnection" & _ Chr(13) & Chr(10) strCode = strCode & " .LockType = adLockPessimistic" & Chr(13) & _ Chr(10) strCode = strCode & " .CursorLocation = adUseServer" & Chr(13) & _ Chr(10) strCode = strCode & " .CursorType = adOpenKeyset" & Chr(13) & _ Chr(10) strCode = strCode & " .Open" & Chr(13) & Chr(10) strCode = strCode & " .AddNew" & Chr(13) & Chr(10) strCode = strCode & _ " For lngFieldCounter = 0 To v_recClientRecordSet.Fields.Count - 1" & _ Chr(13) & Chr(10) strCode = strCode & _ " If Not " & _ "IsNull(v_recClientRecordSet.Fields(lngFieldCounter).Value) Then" & _ Chr(13) & Chr(10) strCode = strCode & _ " .Fields(v_recClientRecordSet.Fields(lngFieldCounter).Name) _" & _ Chr(13) & Chr(10) strCode = strCode & _ " = v_recClientRecordSet.Fields(lngFieldCounter).Value" & _ Chr(13) & Chr(10) strCode = strCode & " End If" & Chr(13) & Chr(10) strCode = strCode & " Next" & Chr(13) & Chr(10) strCode = strCode & " .Update" & Chr(13) & Chr(10) strCode = strCode & " End With" & Chr(13) & Chr(10) strCode = strCode & " Else" & Chr(13) & Chr(10) strCode = strCode & " Set rec" & r_TableInfo(lngTableCounter) & _ " = v_recClientRecordSet" & Chr(13) & Chr(10) strCode = strCode & " Set rec" & r_TableInfo(lngTableCounter) & _ ".ActiveConnection = GetADOConnection" & Chr(13) & Chr(10) strCode = strCode & " If v_bolDelete = True Then" & Chr(13) & Chr(10) strCode = strCode & " rec" & r_TableInfo(lngTableCounter) & _ ".Delete" & Chr(13) & Chr(10) strCode = strCode & " Else" & Chr(13) & Chr(10) strCode = strCode & " On Error Resume Next" & Chr(13) & Chr(10) strCode = strCode & " rec" & r_TableInfo(lngTableCounter) & _ ".Filter = adFilterPendingRecords" & Chr(13) & Chr(10) strCode = strCode & " rec" & r_TableInfo(lngTableCounter) & _ ".UpdateBatch" & Chr(13) & Chr(10) strCode = strCode & " rec" & r_TableInfo(lngTableCounter) & _ ".Filter = adFilterConflictingRecords" & Chr(13) & Chr(10) strCode = strCode & " If rec" & r_TableInfo(lngTableCounter) & _ ".RecordCount > 0 Then" & Chr(13) & Chr(10) strCode = strCode & " Err.Raise 2002, " & Chr(34) & "Update" & _ r_TableInfo(lngTableCounter) & "RS" & Chr(34) & "," & Chr(34) & _ " & Conflicting Errors" & Chr(34) & Chr(13) & Chr(10) strCode = strCode & " End If" & Chr(13) & Chr(10) strCode = strCode & " rec" & r_TableInfo(lngTableCounter) & _ ".Filter = adFilterNone" & Chr(13) & Chr(10) strCode = strCode & " End If" & Chr(13) & Chr(10) strCode = strCode & " End If" & Chr(13) & Chr(10) strCode = strCode & " Set Update" & r_TableInfo(lngTableCounter) & _ "RS = rec" & r_TableInfo(lngTableCounter) & "" & Chr(13) & Chr(10) strCode = strCode & " Set rec" & r_TableInfo(lngTableCounter) & _ " = Nothing" & Chr(13) & Chr(10) strCode = strCode & " Exit Function" & Chr(13) & Chr(10) strCode = strCode & "Update" & r_TableInfo(lngTableCounter) & _ "RSError:" & Chr(13) & Chr(10) strCode = strCode & " Err.Raise Err.Description, " & Chr(34) & _ " & Error Update" & r_TableInfo(lngTableCounter) & "RS" & Chr(34) & _ " & Err.Source, _" & Chr(13) & Chr(10) strCode = strCode & " Err.Description" & Chr(13) & Chr(10) strCode = strCode & "End Function" & Chr(13) & Chr(10)NextstrCode = strCode & _ "Public Function UpdateRecordset(ByVal v_strUserID As String, _" & _ Chr(13) & Chr(10)strCode = strCode & " ByVal v_strPassword As String, _" & _ Chr(13) & Chr(10)strCode = strCode & _ " ByVal v_recClientRecordSet As ADODB.Recordset, _" & Chr(13) & _ Chr(10)strCode = strCode & " ByVal v_eName As TableName, Optional ByVal " & _ " v_strWhereClause As String, " & _ " Optional ByVal v_bolDelete As Boolean = False) " & _ "As ADODB.Recordset" & Chr(13) & Chr(10)strCode = strCode & "On Error GoTo UpdateRecordsetError" & Chr(13) & Chr(10)strCode = strCode & "SetADOConnection v_strUserID, v_strPassword" & _ Chr(13) & Chr(10)strCode = strCode & "Select Case v_eName" & Chr(13) & Chr(10)For lngTableCounter = 1 To UBound(r_TableInfo) strCode = strCode & "Case e_" & r_TableInfo(lngTableCounter) & _ Chr(13) & Chr(10) strCode = strCode & "Set UpdateRecordset = Update" & _ r_TableInfo(lngTableCounter) & _ "RS(v_recClientRecordSet, v_bolDelete)" & Chr(13) & Chr(10)NextstrCode = strCode & "End Select" & Chr(13) & Chr(10)strCode = strCode & "SetComplete" & Chr(13) & Chr(10)strCode = strCode & "CloseADOConnection" & Chr(13) & Chr(10)strCode = strCode & "Exit Function" & Chr(13) & Chr(10)strCode = strCode & "UpdateRecordsetError:" & Chr(13) & Chr(10)strCode = strCode & "CloseADOConnection" & Chr(13) & Chr(10)strCode = strCode & "SetAbort" & Chr(13) & Chr(10)strCode = strCode & "Err.Raise Err.Number, " & Chr(34) & _ "UpdateRecordset" & Chr(34) & " & Err.Source" & Chr(13) & Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10)CreateServer = strCodeEnd Function

VB Proj Man/Code Generator/BuildTop.basAttribute VB_Name = "BuildTop"Option Explicit

Public Function BuildClass(ByRef r_uTableInfo As TableInformation, _ ByVal v_sTableName As String) As StringDim strCode As StringDim lngWhereCounter As LongDim lngQueryKey As LongDim lngQueryCounter As LongstrCode = strCode & "Public Enum ClientDataMember" & Chr(13) & Chr(10)strCode = strCode & "e_" & r_uTableInfo.PrimaryKey & "=" & 1 & Chr(13) & _ Chr(10)strCode = strCode & "End Enum" & Chr(13) & Chr(10)strCode = strCode & "Const m_def_" & r_uTableInfo.PrimaryKey & _ " As String =" & Chr(34) & Chr(34) & Chr(13) & Chr(10)strCode = strCode & "Private WithEvents m_col" & r_uTableInfo.PrimaryKey & _ " As cls" & v_sTableName & "Manager" & Chr(13) & Chr(10)

strCode = strCode & "Const m_def_NumberOf" & v_sTableName & _ "Collections =" & 1 & Chr(13) & Chr(10)

strCode = strCode & "Private m_colDataMembersArray() As cls" & _ v_sTableName & "Manager" & Chr(13) & Chr(10)strCode = strCode & "Private m_blnDataMembersInitialized() As Boolean" & _ Chr(13) & Chr(10)strCode = strCode & "Private m_str" & r_uTableInfo.PrimaryKey & _ "Equals As String" & Chr(13) & Chr(10)strCode = strCode & "Private Sub m_col" & r_uTableInfo.PrimaryKey & _ "_ChangeManagedObjects()" & Chr(13) & Chr(10)strCode = strCode & " ChangeManagedObjects g_cdm" & _ r_uTableInfo.PrimaryKey & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)

strCode = strCode & _ "Private Sub UserControl_ReadProperties(PropBag As PropertyBag)" & _ Chr(13) & Chr(10)strCode = strCode & _ "If UserControl.Ambient.UserMode = False Then Exit Sub" & _ Chr(13) & Chr(10)

strCode = strCode & " Set m_col" & r_uTableInfo.PrimaryKey & _ " = New cls" & v_sTableName & "Manager" & Chr(13) & Chr(10)

strCode = strCode & " m_str" & r_uTableInfo.PrimaryKey & "Equals=" & _ "m_def_" & r_uTableInfo.PrimaryKey & Chr(13) & Chr(10) strCode = strCode & " ReDim m_colDataMembersArray(1 To m_def_NumberOf" & _ v_sTableName & "Collections)" & Chr(13) & Chr(10)strCode = strCode & _ "ReDim m_blnDataMembersInitialized(1 To m_def_NumberOf" & _ v_sTableName & "Collections)" & Chr(13) & Chr(10)strCode = strCode & " Set m_colDataMembersArray(e_" & _ r_uTableInfo.PrimaryKey & ") = m_col" & r_uTableInfo.PrimaryKey & Chr(13) & Chr(10)strCode = strCode & " m_blnDataMembersInitialized(e_" & _ r_uTableInfo.PrimaryKey & ") = False" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)strCode = strCode & "Private Sub UserControl_Terminate()" & Chr(13) & _ Chr(10)strCode = strCode & " Set m_col" & r_uTableInfo.PrimaryKey & _ " = Nothing" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)

strCode = strCode & "Public Function Get" & v_sTableName & _ "Collection(ByVal v_eDataMember As ClientDataMember) _" & Chr(13) & _ Chr(10)strCode = strCode & " As cls" & v_sTableName & "Manager" & _ Chr(13) & Chr(10)strCode = strCode & _ " If m_blnDataMembersInitialized(v_eDataMember) = False Then" & _ Chr(13) & Chr(10)strCode = strCode & " Select Case v_eDataMember" & Chr(13) & Chr(10)strCode = strCode & " Case e_" & r_uTableInfo.PrimaryKey & _ Chr(13) & Chr(10)strCode = strCode & " m_colDataMembersArray(e_" & _ r_uTableInfo.PrimaryKey & ").SetProxyInformation _" & Chr(13) & _ Chr(10)strCode = strCode & " e_" & v_sTableName & " , " & Chr(34) & _ Chr(34) & ", g_cstrField" & r_uTableInfo.PrimaryKey & ", g_cdm" & _ r_uTableInfo.PrimaryKey & Chr(13) & Chr(10)strCode = strCode & "End Select" & Chr(13) & Chr(10)strCode = strCode & " m_colDataMembersArray(v_eDataMember).Refresh" & _ Chr(13) & Chr(10)strCode = strCode & _ " m_blnDataMembersInitialized(v_eDataMember) = True" & Chr(13) & _ Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Set Get" & v_sTableName & _ "Collection = m_colDataMembersArray(v_eDataMember)" & Chr(13) & _ Chr(10)strCode = strCode & "End Function" & Chr(13) & Chr(10)

strCode = strCode & "Private Sub ChangeManagedObjects" & _ " (ByVal v_sDataMember As String)" & Chr(13) & Chr(10)strCode = strCode & " Dim lng" & v_sTableName & "CollNumber As Long" & _ Chr(13) & Chr(10)strCode = strCode & " Dim lngIgnore" & v_sTableName & "Number As Long" & _ Chr(13) & Chr(10)strCode = strCode & " Select Case v_sDataMember" & Chr(13) & Chr(10)strCode = strCode & " Case g_cdm" & r_uTableInfo.PrimaryKey & _ Chr(13) & Chr(10)strCode = strCode & " lngIgnore" & v_sTableName & "Number =" & _ lngWhereCounter & Chr(13) & Chr(10)strCode = strCode & " End Select" & Chr(13) & Chr(10)strCode = strCode & " For lng" & v_sTableName & _ "CollNumber = 1 To m_def_NumberOf" & v_sTableName & "Collections" & _ Chr(13) & Chr(10)strCode = strCode & " If lng" & v_sTableName & "CollNumber lngIgnore" & _ v_sTableName & "Number Then" & Chr(13) & Chr(10)strCode = strCode & " If m_blnDataMembersInitialized(lng" & _ v_sTableName & "CollNumber) = True Then" & Chr(13) & Chr(10)strCode = strCode & " m_colDataMembersArray(lng" & _ v_sTableName & "CollNumber).Refresh" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " End If" & Chr(13) & Chr(10)strCode = strCode & " Next" & Chr(13) & Chr(10)strCode = strCode & "End Sub" & Chr(13) & Chr(10)strCode = strCode & "Public Property Get " & r_uTableInfo.PrimaryKey & _ "Equals() As String" & Chr(13) & Chr(10)strCode = strCode & " " & r_uTableInfo.PrimaryKey & "Equals = m_str" & _ r_uTableInfo.PrimaryKey & "Equals" & Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10) strCode = strCode & "Public Property Let " & r_uTableInfo.PrimaryKey & _ "Equals(ByVal v_strNew" & r_uTableInfo.PrimaryKey & "Equals" & _ " As _" & Chr(13) & Chr(10)strCode = strCode & " String)" & _ Chr(13) & Chr(10)strCode = strCode & " m_str" & r_uTableInfo.PrimaryKey & _ "Equals = v_strNew" & r_uTableInfo.PrimaryKey & "Equals" & _ Chr(13) & Chr(10)strCode = strCode & "End Property" & Chr(13) & Chr(10)BuildClass = strCodeEnd Function

VB Proj Man/Code Generator/CodeGenerator.dll

VB Proj Man/Code Generator/CodeGenerator.expL7.edatad@@.debug$Sf@B7CodeGenerator.dllDllCanUnloadNowDllGetClassObjectDllRegisterServerDllUnregisterServer $(8, 0 If InStr(1, strTempTableName, " ") > 0 Then strTempTableName = _ Mid(strTempTableName, 1, InStr(1, strTempTableName, " ") - 1) & _ Mid(strTempTableName, InStr(1, strTempTableName, " ") + 1, _ Len(strTempTableName)) End If Loop Set objVBproj = VBInstance.VBProjects.Add(vbext_pt_ActiveXControl) objVBproj.Name = "prj" & strTempTableName objVBproj.References.AddFromGuid _ "{00000200-0000-0010-8000-00AA006D2EA4}", 2, 0 objVBproj.References.AddFromGuid _ "{BD96C556-65A3-11D0-983A-00C04FC29E30}", 1, 5 objVBproj.VBComponents.Add (vbext_ct_ClassModule) objVBproj.VBComponents.Item(1).Name = _ "ctl" & strTempTableName

objVBproj.VBComponents.Item("ctl" & strTempTableName).Activate

objVBproj.VBComponents.Item("ctl" & _ strTempTableName).CodeModule.AddFromString _ BuildTop.BuildClass(m_uTables(lngTableCounter), strTempTableName)

objVBproj.VBComponents.Item(objVBproj.VBComponents.Count).Name = _ "cls" & strTempTableName objVBproj.VBComponents.Item("cls" & strTempTableName).Activate

objVBproj.VBComponents.Item("cls" & _ strTempTableName).Properties.Item("DataSourceBehavior").Value = 1 objVBproj.VBComponents.Item("cls" & _ strTempTableName).CodeModule.AddFromString _ BuildBottom.CreateDeclarations objVBproj.VBComponents.Item("cls" & _ strTempTableName).CodeModule.AddFromString _ BuildBottom.CreateInitialize objVBproj.VBComponents.Item("cls" & _ strTempTableName).CodeModule.AddFromString BuildBottom.CreateTerminate objVBproj.VBComponents.Item("cls" & _ strTempTableName).CodeModule.AddFromString _ BuildBottom.CreateChangedField objVBproj.VBComponents.Item("cls" & _ strTempTableName).CodeModule.AddFromString _ BuildBottom.CreateMiscProps(strTempTableName) objVBproj.VBComponents.Item("cls" & _ strTempTableName).CodeModule.AddFromString _ BuildBottom.CreateValidateFields(m_uTables(lngTableCounter).FieldInfo) objVBproj.VBComponents.Item("cls" & _ strTempTableName).CodeModule.AddFromString _ BuildBottom.CreateGetLet(m_uTables(lngTableCounter).FieldInfo)

objVBproj.VBComponents.Add (vbext_ct_ClassModule) objVBproj.VBComponents.Item(objVBproj.VBComponents.Count).Name = _ "cls" & strTempTableName & "Manager" objVBproj.VBComponents.Item("cls" & strTempTableName & _ "Manager").Properties.Item("DataSourceBehavior").Value = 1 objVBproj.VBComponents.Item("cls" & strTempTableName & _ "Manager").Activate

Dim strTempTable() As String ReDim strTempTable(1 To UBound(m_uTables)) Dim lngTableCount As Long For lngTableCount = 1 To UBound(m_uTables) strTempTable(lngTableCount) = m_uTables(lngTableCount).TableName Do While InStr(1, strTempTable(lngTableCount), " ") > 0 If InStr(1, strTempTable(lngTableCount), " ") > 0 Then Dim lngSpace As Long lngSpace = InStr(1, strTempTable(lngTableCount), " ") strTempTable(lngTableCount) = _ Left(strTempTable(lngTableCount), lngSpace - 1) & _ Right(strTempTable(lngTableCount), _ Len(strTempTable(lngTableCount)) - lngSpace) End If Loop Next

objVBproj.VBComponents.Item("cls" & strTempTableName & _ "Manager").CodeModule.AddFromString _ BuildMiddle.CreateDeclarartions(strTempTable, strTempTableName)

Dim bolPrimKeyNum As Boolean Dim lngFieldCounter As Long For lngFieldCounter = 1 To UBound(m_uTables(lngTableCounter).FieldInfo) If LCase(m_uTables(lngTableCounter).PrimaryKey)