private mytable GetTable(string table) { mytable mtable = new mytable(table); SqlConnection conn = new SqlConnection("Server=dmmlenovo1;Database=TheSingingClub;Integrated Security=true"); SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "Select COLUMN_NAME, DATA_TYPE from information_schema.COLUMNS where Table_name = '" + table + "' FOR XML Path('Data'), ROOT('Root')"; conn.Open(); SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { object o = sdr.GetValue(0); if (o != null) { mtable.xml_column += o.ToString(); } } conn.Close(); cmd.CommandText = "Select COLUMN_NAME from information_schema.KEY_COLUMN_USAGE where Table_name = '" + table + "' FOR XML Path('Data'), ROOT('Root')"; conn.Open(); sdr = cmd.ExecuteReader(); while (sdr.Read()) { object o = sdr.GetValue(0); if (o != null) { mtable.xml_index += o.ToString(); } } conn.Close(); return(mtable); }