Hi!
First - be patient my english isn't good
I've got problem in code listed below... While compilation there's no errors, but while execution JITter throw Argument Exception: This row already belongs to another table.
Please look at this code (I marked line where the exception occurs):
--------------------------------------------------------
private static String GetPathInfo(Int32 start, Int32 end, Int32 changeCount, DataTable dtMatrixToDB)
{
DataTable dtStops = new DataTable("Przystanki",
dtTmp = new DataTable();
Int32 i ,j, c, stop, next;
DataColumn dcStop;
DataRow drPath;
String Path = "";
for(i = 0 ; i <= changeCount; i++)
{
dcStop = new DataColumn(i.ToString(),System.Type.GetType("System.Int32");
dcStop.AllowDBNull = true;
dcStop.DefaultValue = null;
dtStops.Columns.Add(dcStop);
}
Path += "\nDodano kolumny";
drPath = dtStops.NewRow();
drPath["0"] = start;
dtStops.Rows.Add(drPath);
dtTmp = dtStops.Clone();
dtStops.AcceptChanges();
dtTmp.AcceptChanges();
for(i = 0; i <= changeCount; i++)
{
Path += "\n for i = " + i.ToString() + ": ";
foreach(DataRow drStops in dtStops.Rows)
{
if(drStops[i.ToString()] != null)
{
stop = Convert.ToInt32(drStops[i.ToString()]);
Path += stop.ToString() + " (";
/*******************************************************/
/*******************************************************/
for(c = 0; c < count; c++)
/*******************************************************/
/*******************************************************/
{
if(mp[stop,pol[c]])
{
Path += pol[c].ToString() + " ";
drPath = dtStops.NewRow();
for(j = 0; j < i; j++)
{
drPath[j.ToString()] = drStops[j.ToString()];
}
drPath[i.ToString()] = pol[c];
dtTmp.Rows.Add(drPath);
}//if(mp[stop,next])
}//for(c = 0; c < count; c++)
Path+= " ";
}//if(drStops[i.ToString()] != null)
}//foreach(DataRow drStops in dtStops.Rows)
dtStops.Clear();
dtStops = dtTmp.Copy();
dtTmp.Clear();
dtStops.AcceptChanges();
dtTmp.AcceptChanges();
}//for(i = 0; i <= changecount; i++)
foreach(DataRow drRigthPath in dtStops.Rows)
{
next = Convert.ToInt32(drRigthPath[changeCount.ToString()]);
if(next != end)
dtStops.Rows.Remove(drRigthPath);
}//foreach(DataRow drRigthPath in dtStops.Rows)
dtStops.AcceptChanges();
Path += "\n";
foreach(DataRow dr in dtStops.Rows)
{
foreach(DataColumn dc in dtStops.Columns)
Path += Convert.ToString(dr[dc]) + " - ";
Path += "\n";
}//foreach(DataRow dr in dtStops.Rows)
return Path;
}
-------------------------------------------
Greetings
Arek
First - be patient my english isn't good
I've got problem in code listed below... While compilation there's no errors, but while execution JITter throw Argument Exception: This row already belongs to another table.
Please look at this code (I marked line where the exception occurs):
--------------------------------------------------------
private static String GetPathInfo(Int32 start, Int32 end, Int32 changeCount, DataTable dtMatrixToDB)
{
DataTable dtStops = new DataTable("Przystanki",
dtTmp = new DataTable();
Int32 i ,j, c, stop, next;
DataColumn dcStop;
DataRow drPath;
String Path = "";
for(i = 0 ; i <= changeCount; i++)
{
dcStop = new DataColumn(i.ToString(),System.Type.GetType("System.Int32");
dcStop.AllowDBNull = true;
dcStop.DefaultValue = null;
dtStops.Columns.Add(dcStop);
}
Path += "\nDodano kolumny";
drPath = dtStops.NewRow();
drPath["0"] = start;
dtStops.Rows.Add(drPath);
dtTmp = dtStops.Clone();
dtStops.AcceptChanges();
dtTmp.AcceptChanges();
for(i = 0; i <= changeCount; i++)
{
Path += "\n for i = " + i.ToString() + ": ";
foreach(DataRow drStops in dtStops.Rows)
{
if(drStops[i.ToString()] != null)
{
stop = Convert.ToInt32(drStops[i.ToString()]);
Path += stop.ToString() + " (";
/*******************************************************/
/*******************************************************/
for(c = 0; c < count; c++)
/*******************************************************/
/*******************************************************/
{
if(mp[stop,pol[c]])
{
Path += pol[c].ToString() + " ";
drPath = dtStops.NewRow();
for(j = 0; j < i; j++)
{
drPath[j.ToString()] = drStops[j.ToString()];
}
drPath[i.ToString()] = pol[c];
dtTmp.Rows.Add(drPath);
}//if(mp[stop,next])
}//for(c = 0; c < count; c++)
Path+= " ";
}//if(drStops[i.ToString()] != null)
}//foreach(DataRow drStops in dtStops.Rows)
dtStops.Clear();
dtStops = dtTmp.Copy();
dtTmp.Clear();
dtStops.AcceptChanges();
dtTmp.AcceptChanges();
}//for(i = 0; i <= changecount; i++)
foreach(DataRow drRigthPath in dtStops.Rows)
{
next = Convert.ToInt32(drRigthPath[changeCount.ToString()]);
if(next != end)
dtStops.Rows.Remove(drRigthPath);
}//foreach(DataRow drRigthPath in dtStops.Rows)
dtStops.AcceptChanges();
Path += "\n";
foreach(DataRow dr in dtStops.Rows)
{
foreach(DataColumn dc in dtStops.Columns)
Path += Convert.ToString(dr[dc]) + " - ";
Path += "\n";
}//foreach(DataRow dr in dtStops.Rows)
return Path;
}
-------------------------------------------
Greetings
Arek