'------Here is the code to delete a user from tblUser objTx.CommandText = "prc_del_tblUser"
objTx.CreateParameter "RETURN_VALUE", adInteger, adParamReturnValue, 0
objTx.CreateParameter "User_ID", adInteger, adParamInput, 4, UserID
lngRetVal = objTx.ExecuteSp
'--------------here is ExecuteSp, one of the functions of a class which handles database transactions
'-------------------------------------------------------
' Name: ExecuteSp
' Description: Executes a stored procedure.
' Parameters: strErrDesc - [OUT] the error message, if an error occurred.
' Returns: An error code if an error occurred, zero otherwise.
'-------------------------------------------------------
Public Function ExecuteSp(Optional ByRef strErrText As String) As Long
On Error GoTo PROC_ERR
' Make sure a connection is open.
Call OpenConnection
m_objCmd.CommandType = adCmdStoredProc
' Execute the stored procedure.
Call m_objCmd.Execute '' PROGRAM BREAKS HERE
ExecuteSp = m_objCmd("RETURN_VALUE")
PROC_EXIT:
Exit Function
PROC_ERR:
ExecuteSp = Err.Number
If Err.Number = -2147217911 Then
MsgBox "You do not have permission to perform this operation. Please contact your System Administrator.", vbCritical, "Invalid Access"
ElseIf Err.Number = 3265 Then
Resume Next
ElseIf Err.Number = -2147217873 Then
MsgBox "Duplicate value! The information will not be saved!"
ElseIf Err.Number = -2147217900 Then
MsgBox "What's this error?"
End If
End Function
'----------------here is the stored procedure copied from SQL2000CREATE PROCEDURE prc_del_tblUser/* ------------------------------------------------------------
PROCEDURE: prc_del_tblUser
DESCRIPTION: Deletes a record from table 'tblUser'
------------------------------------------------------------ */ @User_ID INTEGER AS DELETE FROM [tblUser] WHERE [User_ID] = @User_ID RETURN @@ERROR
objTx.CreateParameter "RETURN_VALUE", adInteger, adParamReturnValue, 0
objTx.CreateParameter "User_ID", adInteger, adParamInput, 4, UserID
lngRetVal = objTx.ExecuteSp
'--------------here is ExecuteSp, one of the functions of a class which handles database transactions
'-------------------------------------------------------
' Name: ExecuteSp
' Description: Executes a stored procedure.
' Parameters: strErrDesc - [OUT] the error message, if an error occurred.
' Returns: An error code if an error occurred, zero otherwise.
'-------------------------------------------------------
Public Function ExecuteSp(Optional ByRef strErrText As String) As Long
On Error GoTo PROC_ERR
' Make sure a connection is open.
Call OpenConnection
m_objCmd.CommandType = adCmdStoredProc
' Execute the stored procedure.
Call m_objCmd.Execute '' PROGRAM BREAKS HERE
ExecuteSp = m_objCmd("RETURN_VALUE")
PROC_EXIT:
Exit Function
PROC_ERR:
ExecuteSp = Err.Number
If Err.Number = -2147217911 Then
MsgBox "You do not have permission to perform this operation. Please contact your System Administrator.", vbCritical, "Invalid Access"
ElseIf Err.Number = 3265 Then
Resume Next
ElseIf Err.Number = -2147217873 Then
MsgBox "Duplicate value! The information will not be saved!"
ElseIf Err.Number = -2147217900 Then
MsgBox "What's this error?"
End If
End Function
'----------------here is the stored procedure copied from SQL2000CREATE PROCEDURE prc_del_tblUser/* ------------------------------------------------------------
PROCEDURE: prc_del_tblUser
DESCRIPTION: Deletes a record from table 'tblUser'
------------------------------------------------------------ */ @User_ID INTEGER AS DELETE FROM [tblUser] WHERE [User_ID] = @User_ID RETURN @@ERROR
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货