Mata

Mata

  • NA
  • 46
  • 34.6k

Writexml method triggering Show Form

Aug 25 2011 7:01 AM
Program worked ok, until I added method which puts this table in xml. I went debugging and on line marked program pops up my windows form and stops (waiting to trigger some event on that form by user (click button etc)). But Form shouldn't apear at this line in code. Why is this happening?
I have just started to learn c# and I'm new to visual studio 2010 (using it on win7 64 bit).Please some advice






private DataTable BuildSampleTable()
{
// ------ Create a sample table to display in the application.
DataTable theTable = new DataTable("SampleTable");
theTable.Columns.Add("ID", typeof(long));
theTable.Columns.Add("StudentName", typeof(string));
theTable.Columns.Add("GradeYear", typeof(int));
theTable.Columns.Add("ScoreTrimester1", typeof(decimal));
theTable.Columns.Add("ScoreTrimester2", typeof(decimal));
theTable.Columns.Add("ScoreTrimester3", typeof(decimal));

// ----- Create a primary key for the table.
theTable.PrimaryKey = new DataColumn[] {theTable.Columns["ID"]};

theTable.Rows.Add(new Object[] {3429L, "Abercrombie, Kim", 12, 4m, 3.9m, 4m});
theTable.Rows.Add(new Object[] {2352L, "Hamlin, Jay", 10, 2.5m, 1.85m, 1.7m});
theTable.Rows.Add(new Object[] {6843L, "Jacobsen, Lola", 10, 2.67m, 2.9m, 3.2m});
theTable.Rows.Add(new Object[] {4810L, "Price, Jeff", 11, 3m, 3m, 3.4m});

theTable.WriteXml(@"c:\mydoc.xml");  // <-------------------------------------------------

return theTable;
}





 

Answers (14)