Программирование в IIS


Пример 1.7


'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'CreateChair 'Generates a new ID, populates object with 'the new ID, writes record to DB ' 'in: nothing 'out: returns true on success and false otherwise '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Public Function CreateChair() As Boolean

On Error GoTo Sub_Error_Handler Const ERROR_MESSAGE_INFO = "CreateChair"

Const COMMAND_PREFIX = "INSERT INTO tblChair" & _ " ([ID], [Color]) VALUES ('" Const COMMAND_CONJUNCTION = "', '" Const COMMAND_SUFFIX = "')"

Dim sNewID As String Dim sSQL As String

'get new ID sNewID = CreateNewID

'build the insert statement sSQL = COMMAND_PREFIX & sNewID & _ COMMAND_CONJUNCTION & m_scolor & COMMAND_SUFFIX

'perform database update If Not ExecuteCommand(sSQL) Then Err.Raise 1001, ERROR_MESSAGE_INFO, _ "Failure updating database table for Chair ID = " & sNewID End If

'set new ID to local setting m_sID = sNewID

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub_Exit_Done: 'return success value CreateChair = True

On Error Resume Next 'destroy objects Exit Function

Sub_Error_Handler: ProcessErr " Failure Creating Chair. ID = " & sNewID

End Function

Листинг 1.7. Function CreateChair

Закрыть окно






Начало  Назад  Вперед



Книжный магазин