g a

g a

  • NA
  • 1
  • 0

well I have some problem

Mar 22 2009 5:11 AM
StreamWriter sw = new StreamWriter("D:\\sss.txt"); DataTable dt = new DataTable(); DataColumn dc = new DataColumn("ID", typeof(string)); dc.AllowDBNull = false; dc.Unique = true; dt.Columns.Add(dc); dt.Columns.Add("FirstName", typeof(string)); dt.Columns.Add("LastName", typeof(string)); dt.Rows.Add(1, "aaa", "bbb"); dt.Rows.Add(2, "ccc", "dddd"); int length = dt.Columns.Count; int length1 = dt.Rows.Count; for (int i = 0; i < length; i++) { sw.Write(dt.Columns[i]+";"); } foreach (DataRow dr in dt.Rows) { sw.Write("\r\n" + dr[0] + " " + dr[1] + " " + dr[2]); } sw.Close(); StreamReader sr = new StreamReader("D:\\sss.txt"); a = sr.ReadLine(); while (a != null) { DataSet d = new DataSet(); Console.Write(a + "\n"); a = sr.ReadLine(); } sr.Close(); as you can see I write from datatable to txt File ad it warks well, but now I want to load it back to datatable like this: In Colums must be ID, FirsName, LastName and in Rows must be 1, "aaa", "bbb"; 2, "ccc", "dddd" what'll you advise me?

Answers (1)