Hi,
This is my method:
public ClsDMLProperties Add(string Column_Name, string Column_Value)
{
mCol = new ArrayList();
ClsDMLProperties returnvalue;
ClsDMLProperties ObjMember = new ClsDMLProperties();
ObjMember.Col_Name = Column_Name;
ObjMember.Col_Value = Column_Value;
try
{
mCol.Add(ObjMember);
}
catch (Exception ex)
{
string msg = ex.Message;
Console.WriteLine(msg);
//DBCONObj.gprocErrorHandler(ex.Source, ex.Message, "Add", "ClsDMLFun");
}
returnvalue = ObjMember;
ObjMember = null;
return returnvalue;
}
==========================
ClsDMLProperties Class
public class ClsDMLProperties
{
private string column_name;
private string column_value;
private bool mvarReplaceBlankWithNull;
private bool mvarAllowNull;
private int mvarField_Decimals;
private bool mvarisNumeric;
public string Col_Name
{
get { return column_name; }
set { column_name = value; }
}
public string Col_Value
{
get { return column_value; }
set { column_value = value; }
}
public bool ReplaceBlankWithNull
{
get { return mvarReplaceBlankWithNull; }
set { mvarReplaceBlankWithNull = value; }
}
public bool AllowNull
{
get { return mvarAllowNull; }
set { mvarAllowNull = value; }
}
public int Field_Decimal
{
get
{ return mvarField_Decimals; }
set
{ mvarField_Decimals = value; }
}
public bool IsNumeric
{
get
{ return mvarisNumeric; }
set
{ mvarisNumeric = value; }
}
}
======================
My problem here is that to that arraylist object what i am adding does not get incremented. What could be the problem?
Loading

Sam HobbsPosted Nov 21, 2011, 6:05 PM
I don't know what you mean by "does not get incremented". Perhaps the problem is that when you set ObjMember to null then that sets the object in the ArrayList to null. That is how C# works; since ClsDMLProperties is a class you are using references to ObjMember and when you set that reference to null then that affects every place that you have used that reference. So you probably do not want to set ObjMember to null.
Another problem is that you create a new mCol every time you call Add; I suspect that you do not want to do that.
B M SuchitraPosted Nov 22, 2011, 1:23 AM
Yes you are right.everytime a new object of Arraylist was getting created. That was the only mistake.. Thanks.
Prabhu RajaPosted Nov 21, 2011, 5:42 AM
{
mCol = new ArrayList();
ClsDMLProperties returnvalue;
ClsDMLProperties ObjMember = new ClsDMLProperties();
ObjMember.Col_Name = Column_Name;
ObjMember.Col_Value = Column_Value;
try
{
mCol.Add(ObjMember);
}
catch (Exception ex)
{
string msg = ex.Message;
Console.WriteLine(msg);
//DBCONObj.gprocErrorHandler(ex.Source, ex.Message, "Add", "ClsDMLFun");
}
returnvalue = ObjMember;
ObjMember = null;
return mCol; //return Arraylist instead of Object (returnvalue)
}
Jean PaulPosted Nov 21, 2011, 4:21 AM
I believe the problem is: You are returning an object instead of the ArrayList.
Try changing the method to: public ArrayList Add