Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Arraylist to Hashtable

Posted on 2006-06-01
Medium Priority
Last Modified: 2008-01-09

I have an arraylist which is built based on a recordset.

                    public ArrayList userRoles=new ArrayList() ;
                    string sqlroles;
                    sqlroles = "Select zrole_id from z360core_user_role where zuser_id="+ UserId ;
                    userRoles = Db.RecordSet(sqlroles);

                    foreach (Hashtable Rl in userRoles)


The output is exactly what I wanted. This means that the data is available in the arraylist and hashtable.

I have someother function, I have a value from the db


I need to check if this value is available in the userRoles arraylist.

If I try to use
if ((userRoles.IndexOf(Convert.ToInt32(Db.ColumnValue("zrole_id")))==-1))
            return false;  
its failing

How should I check if  Convert.ToInt32(Db.ColumnValue("zrole_id")) is there in the userRoles arraylist??

Pls help
Question by:sureshraina
1 Comment

Accepted Solution

salan_alani earned 1500 total points
ID: 16807123
As per your sql select statement, the 'zrole_id' column is in number format (and almost an Int32 format). Therefore your ArrayList will be as the same format for thier objects.
Now I did not understand what is the ColumnValue will retrieve. But anyway, if you want to check if a specified value exist in the userRoles ArrayList, you could use the code below:

int x;
x= 5 // or whatever

    return false;

BTW, why you don't move towards the using of ADO.NET rather thatn the traditional ADO if you are using ASP.NET (aspx) application. It is more relaible, no need to add an ActiveX control, and many other features.

Good luck

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question