All pastes #209758 Raw Edit

Shin-Ra

public text v1 · immutable
#209758 ·published 2006-10-19 09:51 UTC
rendered paste body
public ArrayList GetUserRoles( int UserID )
		{
			ArrayList roles = new ArrayList( );
			DBSqlControls sqc = new DBSqlControls( );
			SqlCommand comm = sqc.CreateCommand( );
			comm.CommandType = CommandType.Text;
			comm.CommandText = @"SELECT db_Group.Name FROM dbGroup INNER JOIN db_UserGroup
								 ON db_UserGroup.GroupID = db_Group.Name WHERE 
								 db_UserGroup.UserID=@UserID";
			comm.Parameters.AddWithValue( "@UserID", UserID );
			SqlDataReader dr;
			try
			{
				dr = comm.ExecuteReader( );
				while ( dr.Read( ) )
				{
					roles.Add( dr["RoleName"].ToString( ) );
				}
			}
			catch ( SqlException ex )
			{
				throw ex;
			}
			finally
			{
				comm.Connection.Close( );
			}
			return roles;
		}