ja0 0 Light Poster

Hi,

I want to clear the content of the DataTable Main, after an error as ocurred. The problem is that I want to try to load the data again without closing the program. The problem is that for the 2nd time loading, it just do not show up the data again at the grid...( I am using windows form )
Sample:

//Global Variables
private DataTable Main = new DataTable();
DataColumn IDCol
DataColumn StringCol
DataRow Row

private loadfcn ()
{  IDCol = null;
   StringCol = null;
   Row = null;
   Main.Columns.Clear();
   Main.Rows.Clear();

   IDCol = new DataColumn("ID", System.Type.GetType("System.Int32"));
   StringCol = new DataColumn("Person", System.Type.GetType("System.String"));

   Main.Columns.Add(IDCol);
   Main.Columns.Add(StringCol);
 
 // below is where I add the data to the DataTable

    Row = Main.NewRow();
    Row["ID"] = 1;
    Row["Person"] = "Me";
    Main.Rows.Add(Row);
   // and the rest of the program ... below is a load button 
   // but I suppose that that the program start from top to down each time
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.