Advertisement
Advertisement
| 07.16.2008 at 01:04AM PDT, ID: 23568755 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: |
Public Function addRole(ByVal roleName As String, ByVal roleWeighting As Integer, ByVal roleStatus As Integer, ByVal userID As Integer) As Boolean
Dim con As New SqlConnection(ConnectionStrings("dev").ConnectionString)
Dim cmd As New SqlCommand("sp_addRole", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@roleName", roleName)
cmd.Parameters.AddWithValue("@roleWeighting", roleWeighting)
cmd.Parameters.AddWithValue("@roleStatus", roleStatus)
cmd.Parameters.AddWithValue("@userID", userID)
Dim result As Boolean = False
Try
con.Open()
cmd.ExecuteNonQuery()
result = True
Catch ex As Exception
JCBSecurity.logEntry(ex.Message, "Class: roles", "Procedure: addRole", roleName, roleWeighting, roleStatus, userID)
result = False
Finally
con.Close()
End Try
Return result
End Function
PROCEDURE sp_addRole
-- Add the parameters for the stored procedure here
@roleName varchar(50),
@roleWeighting int,
@roleStatus int,
@userID int
AS
BEGIN try
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @dtStamp datetime
set @dtStamp = getdate()
insert into dbo.usr_roles (
RoleName,
RoleWeighting,
RoleStatus,
DateCreated,
CreatedBy) values (
@roleName,
@roleWeighting,
@roleStatus,
@dtStamp,
@userID)
-- Log it
Exec dbo.sp_logEntry 'New Role Added', @userID, @roleName, @roleWeighting, @roleStatus
END try
begin catch
If @@TRANCOUNT > 0
ROLLBACK
-- Error log entry
Declare @errMsg nvarchar(4000), @errSeverity int, @errProcedure nvarchar(4000), @errLine int
Select @errMsg = ERROR_MESSAGE(),
@errSeverity = ERROR_SEVERITY(),
@errProcedure = ERROR_PROCEDURE(),
@errLine = ERROR_LINE()
Exec dbo.sp_logEntry 'SYSTEM ERROR', @errMsg, @errSeverity, @errProcedure, @errLine
end catch
|