J
JB
Hello
I am passing an arraylist to be filled with data from pgm1 to pgm2 to
pgm3 where it gets filled, then I pass it back from pgm3 to pgm2 to pgm1
where I will use the data from arraylist. The problem is that I am having
trouble passing the arraylist back and forth. Below is a sample of what I am
trying to do and I would like to know where I am going wrong?
***pgm1:
private void Form1_Load(object sender, System.EventArgs e)
{
string Adr;
string Edr;
int IRows;
ArrayList funcList;
ArrayList arrayData;
arrayData.Add("Adr");
arrayData.Add("Edr");
arrayData.Add("IRows");
funcList.Add("Adr");
funcList.Add("Edr");
funcList.Add("IRows");
funcList = pgm2.AEdr(ArrayList arrayData);
label1.Text = "there are " + funcList.Count + "rows";
}
***pgm2:
public void AEdr(ArrayList arrayData)
{
ArrayList funcList = new ArrayList();
ArrayList objList = new ArrayList();
funcList = pgm3.dataList(objList);
for(int i = 0; i < objList.Count; i++)
{
string adr;
string edr;
int irows;
funcList.adr = objList.adr;
funcList.edr = objList.edr;
funcList.irows = irows++;
arrayData.Add(funcList);
}
return arrayData;
}
***pgm3:
public ArrayList dataList(ArrayList objList)
{
ArrayList(objList) getList = new ArrayList (objList);
SqlConnection connection = new
SqlConnection("Data Source=localhost;Initial Catalog=sDatabase;Integrated
Security=True");
string selectStatement = @"select adr, edr from wdTable";
SqlCommand selectCommand = new SqlCommand(selectStatement,
connection);
SqlDataReader reader;
connection.Open();
reader = selectCommand.ExecuteReader(CommandBehavior.SingleResult);
while (reader.Read())
{
objList getList = new objList
((string)reader["adr"],(string)reader["edr"]);
getList.Adr = (string)reader["adr"];
getList.Edr = (string)reader["edr"];
objList.Add(getList);
}
reader.Close;
connection.Close();
return objList;
}
Thanks
JB
I am passing an arraylist to be filled with data from pgm1 to pgm2 to
pgm3 where it gets filled, then I pass it back from pgm3 to pgm2 to pgm1
where I will use the data from arraylist. The problem is that I am having
trouble passing the arraylist back and forth. Below is a sample of what I am
trying to do and I would like to know where I am going wrong?
***pgm1:
private void Form1_Load(object sender, System.EventArgs e)
{
string Adr;
string Edr;
int IRows;
ArrayList funcList;
ArrayList arrayData;
arrayData.Add("Adr");
arrayData.Add("Edr");
arrayData.Add("IRows");
funcList.Add("Adr");
funcList.Add("Edr");
funcList.Add("IRows");
funcList = pgm2.AEdr(ArrayList arrayData);
label1.Text = "there are " + funcList.Count + "rows";
}
***pgm2:
public void AEdr(ArrayList arrayData)
{
ArrayList funcList = new ArrayList();
ArrayList objList = new ArrayList();
funcList = pgm3.dataList(objList);
for(int i = 0; i < objList.Count; i++)
{
string adr;
string edr;
int irows;
funcList.adr = objList.adr;
funcList.edr = objList.edr;
funcList.irows = irows++;
arrayData.Add(funcList);
}
return arrayData;
}
***pgm3:
public ArrayList dataList(ArrayList objList)
{
ArrayList(objList) getList = new ArrayList (objList);
SqlConnection connection = new
SqlConnection("Data Source=localhost;Initial Catalog=sDatabase;Integrated
Security=True");
string selectStatement = @"select adr, edr from wdTable";
SqlCommand selectCommand = new SqlCommand(selectStatement,
connection);
SqlDataReader reader;
connection.Open();
reader = selectCommand.ExecuteReader(CommandBehavior.SingleResult);
while (reader.Read())
{
objList getList = new objList
((string)reader["adr"],(string)reader["edr"]);
getList.Adr = (string)reader["adr"];
getList.Edr = (string)reader["edr"];
objList.Add(getList);
}
reader.Close;
connection.Close();
return objList;
}
Thanks
JB