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


Пример 1.9


'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'ExecuteCommand

'sends a SQL command text to the datasource

'without expectation of return value

'

'in: vsSource - SQL string to execute

'out: returns true on success, false otherwise

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Private Function ExecuteCommand(ByVal vsSource As String) _

As Boolean

On Error GoTo Sub_Error_Handler

Const ERROR_MESSAGE_INFO = "ExecuteCommand"

Dim cmdRequested As ADODB.Command

'establish connection

If m_Connection.State <> adStateOpen Then

Err.Raise 1001, ERROR_MESSAGE_INFO, _

"Connection Object is not open. Database connect be opened."

End If

'establish command

Set cmdRequested = CreateObject("ADODB.Command")

Set cmdRequested.ActiveConnection = m_Connection

'set up command object

cmdRequested.CommandType = adCmdText

cmdRequested.CommandText = vsSource

'run SQL

cmdRequested.Execute

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sub_Exit_Done:

'return success value

ExecuteCommand = True

On Error Resume Next

'destroy objects

Set cmdRequested = Nothing

Exit Function

Sub_Error_Handler:

ProcessErr " Failure executing SQL command."

End Function




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



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