Actually i am converting a datareader to arraylist.
----------
arrOracleParams[0] = objDB.BuildOracleParameter("Product",
System.Data.OracleClient.OracleType.VarChar,
ParameterDirection.Input,Product,50);
arrOracleParams[1] = objDB.BuildOracleParameter("Type",
System.Data.OracleClient.OracleType.VarChar,
ParameterDirection.Input,Type,20);
arrOracleParams[2] = objDB.BuildOracleParameter("pCursor",
System.Data.OracleClient.OracleType.Cursor,
ParameterDirection.Output,null,0);
OracleDataReader objOraReader =
objDB.RunExecuteOracleDataReader("pkg_Prod.sp_get_CP", arrOracleParams);
while (objOraReader.Read())
{
object[] values = new object[objOraReader.FieldCount];
objOraReader.GetValues(values);
alList.Add(values);
}
return alList;
------
Karl Seguin said:
alLCPList itself is an arraylist, because, as you say, GetLCPack returns an
arraylist...but what does the items within the array list contain?
ArrayList arr = new ArrayList()
arr.Add("1");
arr.Add("2");
arr.Add("3");
string value = (string)arr[1];
ArrayList arr = new ArrayList()
arr.Add(1);
arr.Add(2);
arr.Add(3);
int value = (int)arr[0];
ArrayList arr = new ArrayList()
arr.Add(new DataSet());
arr.Add(new DataSet());
arr.Add(new DataSet());
DataSet value = (DataSet)arr[2];
if you are casting an item of the arraylist to arraylist, than this item
must be an arraylist, ala:
ArrayList arr = new ArrayList()
arr.Add(new ArraList());
arr.Add(new ArraList());
arr.Add(new ArraList());
ArraListvalue = (ArraList)arr[1];
If you are getting an invalid cast, then the items within your alLCPlist
ArrayList aren't embedded ArrayLists..
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
gane kol said:
Well, the code before the for loop is
--------
ArrayList alLCPlist = new ArrayList();
DataRow dr;
for (int i=0;i<infoNode.ChildNodes.Count;i++)
{
currentNode = infoNode.ChildNodes
;
alLCPlist = product.GetLCPack(strvalue,
currentNode.Attributes["Name"].Value.ToString());
if (alLCPlist.Count > 0)
{
------
alLCPlist gets the data returned from the dataaccess layer.
product.GetLCPack returns an arraylist.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message Without seeing what alLCPlist is and how it's populated, it's quite hard
to
help. Clearly,alLCPlist doesn't contain arraylists...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Hi,
I have a code that creates a datatable from an arraylist, but i am
getting
an error in casting in
for (int intRow = 0; intRow < alLCPlist.Count; intRow++)
{
DataRow drow = dtLCPack.NewRow();
int intColCount = dtLCPack.Columns.Count;
ArrayList arrlRow = (ArrayList)alLCPlist[intRow]; <== Specified
cast
is not valid here
for (int intCol=0; intCol < intColCount; intCol++)
{
drow[intCol] = arrlRow[intCol];
}
dtLCPack.Rows.Add(drow);
}
Can someone help me how to fix it?
Thanks
Gane